I want to use array of objects(in data.h file) to my user.h file .i tried this thing as below but my try is not succeed .i want help from you guys .what is wrong in my script. please correct me
// data.h file
class data
{
private:
int id;
char name;
public:
data();
int getid()
{
return id;
}
void setid(int id)
{
id = id;
}
char getname()
{
return name;
}
void setname(char name)
{
name=name;
}
};
//data.cpp file
data::data(){
int xyz;
char pqr;
data firstobject;
firstobject.setid(10);
xyz=firstobject.getid();
firstobject.setname(hello);
pqr=firstname.getname();
return 0;
}
//user.h file
class user
{
private:
vector<data> data11;
public:
user();
void add_element(int a)
{
data11.push_back(a);
}
void get_element()
{
for(int x=0; x<data11size(); x++)
{
cout<<data11[x]<<" \n";
};
cout<<" \n";
}
};
//user.cpp file
user::user()
{ user object;
object.add_element(xyz);
object.get_element();
}