Inheritance??

This is a discussion on Inheritance?? within the C++ Programming forums, part of the General Programming Boards category; Hi, In a moment of madness I have forgotten what is going on below, I think its inheritance: Code: TownList::Townlist( ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    4

    Red face Inheritance??

    Hi, In a moment of madness I have forgotten what is going on below, I think its inheritance:

    Code:
    TownList::Townlist( )
    { 
         start = NULL;
         end = NULL;
    }

    Townlist() is inherited by TownList??Hence the '::' Or could itbe implementation?

    Any help would be super, thanks.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    That is the implementation of TownList's constructor.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    4
    Quote Originally Posted by matsp View Post
    That is the implementation of TownList's constructor.

    --
    Mats
    Thanks!

  4. #4
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    The two tokens are different: TownList vs Townlist. I was going to say constructor too, but the OP, I think, recognizes the difference.

    Is that valid?

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I think that's just a typo - if it isn't, then it's implementing a member function (which should have a return type specifier) - and whilst it's technically valid to change the case of one letter in a name, it's BAD design to differentiate the name on such a small thing - just BOUND to make someone make a mistake in one way or another.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Jan 2008
    Posts
    4
    Quote Originally Posted by matsp View Post
    I think that's just a typo - if it isn't, then it's implementing a member function (which should have a return type specifier) - and whilst it's technically valid to change the case of one letter in a name, it's BAD design to differentiate the name on such a small thing - just BOUND to make someone make a mistake in one way or another.

    --
    Mats
    I am revising linked lists and this was part of my revision page. But I couldn't remember what the '::' were being used for. This part of code, I used on the OP is creating an empty linked list in main.

    sorry for any confusion

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, but the question is: Are you INTENTIONALLY using a TownList::Townlist, or is that a typo?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Registered User
    Join Date
    Jan 2008
    Posts
    4
    Quote Originally Posted by matsp View Post
    Yes, but the question is: Are you INTENTIONALLY using a TownList::Townlist, or is that a typo?

    --
    Mats
    Oh ok, yes I have a class of TownList. This is the list class. Then, there is a class called TownNode.

    If I wanted to add the first node to the list, I would do:

    Code:
    TownList::addFirstTown( string name )
    { 
         TownNode* current  = new TownNode ( name );
         start = current;
         end = current;
    }

  9. #9
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    I think that means yes, it was a typo. A consistently wrong typo.

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,556
    Quote Originally Posted by talksr View Post
    Oh ok, yes I have a class of TownList. This is the list class. Then, there is a class called TownNode.

    If I wanted to add the first node to the list, I would do:

    Code:
    void TownList::addFirstTown( string name )
    { 
         TownNode* current  = new TownNode ( name );
         start = current;
         end = current;
    }
    No you wouldn't because that won't compile. You forgot a return type.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 06-08-2009, 03:03 PM
  2. Multiple Inheritance - Size of Classes?
    By Zeusbwr in forum C++ Programming
    Replies: 10
    Last Post: 11-26-2004, 08:04 AM
  3. inheritance and performance
    By kuhnmi in forum C++ Programming
    Replies: 5
    Last Post: 08-04-2004, 12:46 PM
  4. Inheritance and Polymorphism
    By bench386 in forum C++ Programming
    Replies: 2
    Last Post: 03-18-2004, 09:19 PM
  5. Inheritance vs Composition
    By Panopticon in forum C++ Programming
    Replies: 11
    Last Post: 01-20-2003, 03:41 AM

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