P
Piotre Ugrumov
I have done the overload on the operator >> and << in the class Attore.
These 2 overload work correctly.
I have done the overload of the same overload in the class Film. The class
film ha inside an array of pointer to Attore.
I have written these overload in these ways. the overload of << work
correctly the overload of >> I don't know. I compile the class correctly,
when I insert a film through the operator >> I don't receive error, but when
I try to stamp the fil through the operator << I have an error during the
execution of program. Why this error? Depend from the overload of >>.
There are the overload of the operator<< and >>:
ostream & operator<<(ostream &out, const Film &f){
out<<f.getTitolo()<<endl;
out<<f.getAnno()<<endl;
for(int i=0; i<f.countAttori(); i++){
out<<*(f.attori)<<endl; //use the overload of << in Attore, in Film I
have defined: Attore *attori[5]; this overload works correctly
}
return out;
}
istream & operator>>(istream &in, Film &f){
char nome[30];
int anno;
Attore a;
in>>nome;
in>>anno;
in>>a; //I use the overload of >> in Attore;
f.setTitolo(nome);
f.setAnno(anno);
f.addAttore(a);
return in;
}
how can i resolve this problem?
Thanks
These 2 overload work correctly.
I have done the overload of the same overload in the class Film. The class
film ha inside an array of pointer to Attore.
I have written these overload in these ways. the overload of << work
correctly the overload of >> I don't know. I compile the class correctly,
when I insert a film through the operator >> I don't receive error, but when
I try to stamp the fil through the operator << I have an error during the
execution of program. Why this error? Depend from the overload of >>.
There are the overload of the operator<< and >>:
ostream & operator<<(ostream &out, const Film &f){
out<<f.getTitolo()<<endl;
out<<f.getAnno()<<endl;
for(int i=0; i<f.countAttori(); i++){
out<<*(f.attori)<<endl; //use the overload of << in Attore, in Film I
have defined: Attore *attori[5]; this overload works correctly
}
return out;
}
istream & operator>>(istream &in, Film &f){
char nome[30];
int anno;
Attore a;
in>>nome;
in>>anno;
in>>a; //I use the overload of >> in Attore;
f.setTitolo(nome);
f.setAnno(anno);
f.addAttore(a);
return in;
}
how can i resolve this problem?
Thanks