()'s in constructors

This is a discussion on ()'s in constructors within the C++ Programming forums, part of the General Programming Boards category; why in a child class def do we not use ()'s after the parent, but in the construct we do? ...

  1. #1
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266

    ()'s in constructors

    why in a child class def do we not use ()'s after the parent, but in the construct we do?

    Code:
    class fun: public firecrackers{
    //......
    fun::fun: firecrackers()

  2. #2
    geek SilentStrike's Avatar
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    1,141
    class fun: public firecrackers{ // class fun is derived from class firecrackers
    //......
    fun::fun: firecrackers() // illegal

    // should be

    fun::fun() :
    firecrackers() // call firecrackers default constructor
    Prove you can code in C++ or C# at TopCoder, referrer rrenaud
    Read my livejournal

  3. #3
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266
    hey, SS, you're right i just missed the fun(). but you didn't answer answer why we don't put the firecracker() in the class def but in the constructor.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Arrays and Constructors
    By Verdagon in forum C++ Programming
    Replies: 1
    Last Post: 07-20-2005, 07:20 PM
  2. A question about constructors...
    By Wolve in forum C++ Programming
    Replies: 9
    Last Post: 05-04-2005, 04:24 PM
  3. constructors, arrays, and new
    By Thantos in forum C++ Programming
    Replies: 6
    Last Post: 05-30-2004, 06:21 PM
  4. constructors in classes
    By Kenman in forum C++ Programming
    Replies: 16
    Last Post: 07-28-2003, 07:35 AM
  5. Copy constructors and private constructors
    By Eibro in forum C++ Programming
    Replies: 5
    Last Post: 11-24-2002, 09:16 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21