I am trying to create an object of class Car inside class Auto.Car has a constructor that receives an int parameter.When I declare the object, I am not able to send this parameter to Car constructor, I get errorC2059:sintax error 'constant'.Here is the code:
class Car
{
private:
int sides;
public:
Car(int nsides)
{
sides=nsides;
}
};
class Auto
{
private:
Car test(5);
public:
Auto()
{
}
};
Does anyone has an idea how to send a parameter to constructor?
Thanks, it worked for this simple example, but I am having a hard time on a more complex program. when I called the ctor with initializer list and built it, I had a compiler error saying that default constructor for Car class is missing. I added it(Car(){}) and now the objects testa and testb are using default constructor.