Thread: inheritence problem

  1. #1
    Registered User
    Join Date
    Feb 2010

    inheritence problem

    hi i have a problem with this example that i copy online and is not working can someone help me
    using namespace std;
    class person
                int age;
               person(int age){ this -> age =age;}
    class basketballplayer:public person 
                 int point;
                 int steal;
                basketballplayer(int point, int steal, int age):person(age)
                  this -> point = point;
                  this -> steal = steal;
          basketballplayer tony; //why  is this not working

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Katy, Texas
    You have declared tony as a bb player, but you have not instantiated tony.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  3. #3
    Registered User
    Join Date
    Feb 2010
    what is instantiated tony

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    The basketballplayer constructor requires 3 arguments, but you have supplied none.
    I'd also suggest properly indenting the code, making the member variables private.
    And finally making main return int, or the code will not compile.

    basketballplayer tony(100, 100, 10000);
    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. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM