Why the code cannot be compiled?

Discussion in 'C++' started by ccs, Jun 12, 2004.

  1. ccs

    ccs Guest

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

    Since CEngine does have a constructor taking three parameters.

    class CEngine
    CEngine(int a, int b, int c) {}

    class CCar
    CEngine e(1,2,3);

    Thanks in advance!
    ccs, Jun 12, 2004
    1. Advertisements

  2. ccs

    Pete C. Guest

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

    - Pete
    Pete C., Jun 12, 2004
    1. Advertisements

  3. ccs

    David Harmon Guest

    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.
    David Harmon, Jun 13, 2004
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.