0

Why does this Code result in an Error?

My Code is executed perfectly but, after the executing my .exe data will send me a errormessage that is telling me that my programm is'nt getting executed properly because of an Error. My Code: #include <iostream> using namespace std; class Opp { private: string Farbe; string Name; string Herkunft; public: Opp(string _Farbe,string _Name , string _Herkunft): Farbe(_Farbe),Name(_Name),Herkunft(_Herkunft) {} Opp operator==(Opp &obj){ if (this->Farbe == obj.Farbe){ cout << "\nHey! Wir haben die selbe Farbe. Es ist die Farbe "<<obj.Farbe; } else if (this->Name == obj.Name){ cout <<"\nHey! Wir haben den selben Namen. Wir haben den Namen "<<obj.Name; } else if (this->Herkunft == obj.Herkunft){ cout<<"\nHey! Wir haben die selbe Herkunft. Wir kommen aus "<<obj.Herkunft; } else{ cout<<"\nWir haben leider nichts Gemeinsam! :^("<<endl; } } }; int main(){ Opp obj1("Rot","Q74LMAO","Mars"); Opp obj2("Blau","P-Jay","Mars"); obj1 == obj2; } output: Hey! Wir haben die selbe Herkunft. Wir kommen aus Mars Process returned -1073741819 (0xC0000005) execution time : 1.340 s Press any key to continue.

17th Dec 2016, 4:45 PM
ekko
ekko - avatar
1 Respuesta
0
i didn't even look at your code but i see you dont have " return 0; "at the end...so try that
17th Dec 2016, 5:56 PM
Leonida17st
Leonida17st - avatar