Code:
#include <iostream>
using namespace std;
class Car {
int id;
public:
Car () {cout << "1";}
Car (const Car& cr) {
cout << "2";
}
Car& operator= (const Car& rhs) {
cout << "3";
return *this;
};
int main () {
Car a, b(a);
Car c, d=c;
a=c;
}
#include <iostream>
using namespace std;
class Car {
int id;
public:
Car () {cout << "1";}
Car (const Car& cr) {
cout << "2";
}
Car& operator= (const Car& rhs) {
cout << "3";
return *this;
};
int main () {
Car a, b(a);
Car c, d=c;
a=c;
}
Moze li mi neko objasniti zasto se ovdje dvaput u rjesenju pojavljuje 12
obzirom da je rjesenje 12123