Im am writing a code using the concept of Composition: Objects as Members of Classes and this error appeared for me: [Error] no match to 'operator<<'. Any one can help me? The error started appearing when i tried to include the trabalhador.h and trabalhador.cpp files. If i try to compile the code without this two files it works but i need bouth because im trying to implement this concept by my own.
Here is the code:
//main
#include <iostream>
using std::cout;
#include "trabalhador.h"
int main()
{
cout << "INFORME OS DADOS SOLICITADOS: \n\n";
cout << "Nome do funcionario: ";
info i1;
cout << "CPF: ";
info i2;
trabalhador t(i1, i2);
return 0;
}
//trabalhador.h
#ifndef TRABALHADOR_H
#define TRABALHADOR_H
#include "info.h"
class trabalhador
{
public:
trabalhador (const info &, const info &);
void print () const;
private:
const info funcionarioNome;
const info funcionarioCPF;
};
#endif
//trabalhador.cpp
#include <iostream>
using std::cout;
#include "trabalhador.h"
#include "info.h"
trabalhador::trabalhador (const info &infoNome, const info &infoCPF)
:funcionarioNome (infoNome),
funcionarioCPF (infoCPF)
{
cout << "Dados do funcionario: ";
}
void trabalhador::print() const
{
cout << funcionarioNome << funcionarioCPF;
}
//info.h
#include <string>
using std::string;
#ifndef INFO_H
#define INFO_H
class info
{
public:
info (string = "");
void setInfoDado (string);
void setInfo ();
private:
string infoDado;
};
#endif
//info.cpp
#include <iostream>
using std::cout;
using std::cin;
#include <string>
using std::string;
using std::getline;
#include "info.h"
info::info (string info)
{
setInfoDado (info);
}
void info::setInfoDado (string info)
{
infoDado = info;
setInfo();
}
void info::setInfo ()
{
string nome;
getline (cin, nome);
infoDado = nome;
}