Error in Construct code

Hi All,

I would like to know what is the error in the following program, when I compile it shows me syntax error I have done everything to rectify up to my knowledge but I couldn’t so pls help me.

public static Car construct(CarGroup carGroup)
Car car;
switch (carGroup)
case CarGroup::Economy :
car = new Car_Economy();
case CarGroup::Compact :
car = new Car_Compact();
case CarGroup::MidSize :
car = new Car_MidSize();
case CarGroup::Luxury :
car = new Car_Luxury();
return car;



Please, if you get a compilation error, never forget to tell us the error message and on which line it occurs.

I don’t see anything syntactically wrong in your code, but it assumes certain enum elements, classes and parameterless constructors. If you get a compilation error, one of these assumptions in probably wrong.