just as the title says i have a problem with serializzing class which has a pointer to class. so this is a mock-up of my class structure
class X{
private:
int number;
public:
int set_number(int);
int get_number(void);
//I'm defining the stream operators so class will act as primitive data type
friend istream& operator>>(istream& in,X& x)
{
in>>x.number;
return in;
}
friend ostream& operator<<(ostream& out,const X& x)
{
out<<x.number<<endl;
return out;
}
};//classX
class A{
vector<X*> Ccontainer;
public:
friend ostream& operator<<(ostream& out,const A& a)
{
out<<(int)Ccontainer.size()<<endl;
for(int i=0;i<=Ccontainer.size();i++)
out<<Ccontainer.at(i)<<endl;
return out;
}
friend istream& operator>>(istream& in,A& a)
{
int n;
in>>n;
a.CContainer.reserve(n);
for(int i=0;i<=n;i++)
in>>a.Ccontainer[i];
return in;
}
};//class A
i'm having problems with the second class;the problem is with the insertion operator,what am I missing here?