HELP with class declaration/ initialization

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jjh
    New Member
    • Sep 2006
    • 21

    HELP with class declaration/ initialization

    So this is part ofthe code that I have written
    class TimeLogger: public Node {

    private:
    List list;
    Node *&curr;
    public:
    TimeLogger()
    {
    curr = 0;
    }
    with in main I call TimeLogger tL and so at first it told me that my problem was that I didnt have an appropriate default constructor, so I put a constructor in, and now I get this:

    error C2758: 'TimeLogger::cu rr' : must be initialized in constructor base/member initializer list

    Any Ideas????
  • Jai Vrat Singh
    New Member
    • Oct 2006
    • 18

    #2
    Because you are delaring it as a reference... all references mut me intialised in the intialisation list of the Ctor rather than the body for Ctor.. Reason is obvious.. reference point to a definite memory as soon as they come into existence..

    I hope you understand diff between intializer list and assignment inside Ctor body.. if not, then reply back ..or you may find it in any std text.

    Comment

    Working...