czesc,
przeładowuje (przeciążam) operatory strumienia << i >> . Operatory są zaprzyjaźnione z klasami. Składniowych błędów kompilator mi nie wyrzuca. Jednak rezultat przy uzyciu operatora wyjścia jest w postaci ciagu cyfr "8978413",
Natomiast kiedy chce użyć w kodzie operatora wejścia to intellisense podświetla mi: "Theres no operator ">>" matching these operands" . No a przecież jest, bo go przeciążyłem?
ostream& operator<<(ostream&, const CStudent&);
istream& operator>>(istream&, CStudent&);
int main()
{
CCzlowiek* Student;
Student = new CStudent(3); // student trzeciego semestru
//cout << "/nWprowadz dane studenta";
Student->Dane();
cout << Student; // jest okey, ale rezultat jest nie ten.
cin >> Student; // tutaj podswietla ">>" "Theres no operator ">>" matching these operands"
cin.clear();
cin.sync();
cin.get();
return 0;
}
ostream& operator<<(ostream& out, const CStudent & T)
{
out << T.name << " " << T.surname << " " << T.age << endl
<< "Kierunek: " << T.kierunek << " Wydzial: " << T.wydzial << " Semestr: " << T.semestr << endl;
return out;
};
istream& operator>>(istream& in, CStudent & T)
{
cout << "\nImie: ";
in >> T.name;
cout << "\nNazwisko: ";
cin >> T.surname;
cout << "\nWiek: ";
in >> T.age;
cout << "\nPlec: ";
in >> T.sex;
cout << "\nKierunek: ";
in >> T.kierunek;
cout << "\Wydzial: ";
in >> T.wydzial;
cout << "\nSemestr: ";
return in;
}