#include <iostream>
#include <cstdlib>
using namespace std;
class Passenger {
private:
int ticket ;
int half ;
public:
Passenger(int ticket=rand() % 2, int half=rand() % 2) { // Construct passenger
cout << "passenger was constructed with " << ticket << " ticket and " << half << " half ticket" <<endl;
}
~Passenger() {
cout << "passenger was destructed" <<endl;
}
int getTicket()const{
cout << ticket <<endl;
return ticket;
};
int getHalf()const{
return half;
};
};
int main(){
Passenger m;
m.getTicket();
}
getTicket always prints 64 instead of the 0 or 1 that prints when the constructor is called
I couldn't fix it with this and i dont know that many things for rand()
Aucun commentaire:
Enregistrer un commentaire