mean of the last : in members declaration

This is a discussion on mean of the last : in members declaration within the C++ Programming forums, part of the General Programming Boards category; what is the meaning of the last :class() declaration on the the folowing member function definition.? Code: CLASSX::CONSTRUCTORX (params, ..) ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    2

    Unhappy mean of the last : in members declaration

    what is the meaning of the last :class() declaration on the the folowing member function definition.?
    Code:
    CLASSX::CONSTRUCTORX (params, ..) :CLASSY(param2){
    ...
    }
      I know that :
    class CLASSX: public CLASSY
    {
    ...
    CONSTRUCTORX(param,..)
    }
    and
    the class CLASSY have a constructor with one param.
    First I think that it is for call the CLASEY construsctor but, if CLASSY<--CLASSX i suppose that the constructor CLASSY cosntructor is calling by default.
    or not?
    help please!

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    The : indicates an initializer list. This is where base class constructors are called and member variables are initialized. If you leave it out, the default constructor for CLASSY will be called, but sometimes you want to or have to call a different constructor than the default constructor. You do that by using the initializer list.

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    note that in the same way you can also initialize the member vars
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  4. #4
    Registered User
    Join Date
    Jan 2007
    Posts
    2

    Smile Thanks you

    Thanks you, boys

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 02:49 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 07:13 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

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