In class Persoana, how to use the constructors? In main i will get errors with p1 and p2 objects because of that. I am not allowed the change the main() or to add more private data.
#include <string.h>
#include <cstdlib>
#include <iostream>
using namespace std;
class Profesie
{
public:
Profesie(string r, int s) //constructor
{
setRol(r);
setSalariu(s);
}
string setRol(string job){ rol=job;} //functii getter si setter pentru datele membre
string getRol(){return rol;}
void setSalariu(int s){ salariu = s;}
int getSalariu(){return salariu;}
// string setJob(string job, int s){rol=job, s=salariu;}
ostream& operator<<(ostream&);
private://datele membre
string rol;
int salariu;
};
class Persoana
{
public:
//constructor
Persoana(string n, string p, string g, int n) //: Job(j)
{
In constructor 'Persoana::Persoana(std::string, std::string, Profesie&)':
[Error] 'class Profesie' has no member named 'Job'
In member function 'std::string Persoana::setnume(std::string)':
[Error] 'nume' was not declared in this scope
In member function 'std::string Persoana::setprenume(std::string)':
[Error] 'prenume' was not declared in this scope