Thank you all for the many responses.
Well, the author used that C/C++ hybrid style, no idea why he did it, but I'll stick to C++ from now on.
Got another issue regarding overloading operators, (the variables are german language , it's basically just adding some class attributes of two objects)
It basically doesn't work, c1 just stays like it is, and isn't added with c2.
The operator isn't syntax-highlighted anymore when I write a + behind it, that's why I think it could be a problem with the compiler.
But maybe I just made a mistake somewhere, maybe it works with your compiler?
Code:
//============================================================================
// Name : Operatorenueberladen.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
class stellarobjekt{
double laenge, breite, hoehe;
public:
stellarobjekt(int laenge, int breite, int hoehe){
this->laenge= laenge;
this->breite =breite;
this->hoehe = hoehe;
}
stellarobjekt operator+ (stellarobjekt sto){
stellarobjekt tmp = (*this);
tmp.laenge += sto.laenge;
tmp.breite += sto.breite;
tmp.hoehe += sto.hoehe;
return (tmp);
}
void ausgabe(){
cout << laenge << " " << breite << " " << hoehe << endl;
}
};
int main() {
stellarobjekt c1(300, 400, 500);
stellarobjekt c2(500, 700, 8000);
c1.ausgabe();
c2.ausgabe();
c1 = c1 + c2;
c1.ausgabe();
return 0;
}