Why the code cannot be compiled?

C

ccs

The compile error is: error C2059: syntax error : 'constant'.

Since CEngine does have a constructor taking three parameters.

class CEngine
{
public:
CEngine(int a, int b, int c) {}
};

class CCar
{
CEngine e(1,2,3);
....
};

Thanks in advance!
 
P

Pete C.

ccs said:
The compile error is: error C2059: syntax error : 'constant'.

Since CEngine does have a constructor taking three parameters.

class CEngine
{
public:
CEngine(int a, int b, int c) {}
};

class CCar
{
CEngine e(1,2,3);
...
};

Thanks in advance!

class Car
{
Engine e;
Car() : e(1, 2, 3) {}
};

- Pete
 
D

David Harmon

class Car
{
Engine e;
Car() : e(1, 2, 3) {}
};

Except that the class was named "CEngine". But I would like to
suggest, avoid naming classes with the initial capital C, since
Microsoft has adopted that prefix for many of theirs (since the days
before "namespace" was available) and it is most useful to name your
classes in such a way that they are easily distinguishable from others.
So "Engine" it may be after all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top