I have to make class Car with constructor which catch power and owner. Objects are typed static, not getting data from user. And my homework look like - "wrong values of arguments for constructor should be reported using exceptions". Is that possible ? When I try to type int where conctructor want string I have compilator error. So how can i catch type of variable if program can't be compiled ?
class Car{
public:
string owner;
int power;
Car(string owner, int power)
{
this->owner=owner;
this->power=power;
}
};
Compilation error
int main()
{
Car *Fiat = new Car(15, 1200);
}