Results 1 to 5 of 5

Thread: Which class should be instantiated in from base or derived class ?

  1. #1
    Join Date
    Dec 2010
    Posts
    38

    Which class should be instantiated in from base or derived class ?

    I want to be a programmer but not a professional one , just a simple programmer ,but I am weak in certain area, I have got ATKT in a C sharp , but cleared the rest of the subjects , My doubt was in inheritance, whenever any child class is created, then sometime I get confused that of which class the object will be created. Please help me as early as possible because I do not like to study from books, I prefer internet studies.

  2. #2
    Join Date
    May 2009
    Posts
    511

    Re: Which class should be instantiated in from base or derived class ?

    Whichever language you consider, whether it be Java or C# or any other object oriented programming language, As far as my knowledge is concerned the object of the derived class is created , and then that derived class is used to access the methods and data members of the base class . After instantiating a derived class the, it is used call the methods of both the derived and the base .

  3. #3
    Join Date
    May 2009
    Posts
    511

    Re: Which class should be instantiated in from base or derived class ?

    Whichever language you consider, whether it be Java or C# or any other object oriented programming language, As far as my knowledge is concerned the object of the derived class is created , and then that derived class is used to access the methods and data members of the base class . After instantiating a derived class the, it is used call the methods of both the derived and the base .

  4. #4
    Join Date
    May 2009
    Posts
    543

    Re: Which class should be instantiated in from base or derived class ?

    Well I do not think so , you can create the object of both the derived class and the base class , who says so that the object is created for the derived class only. I agree in case of inheritance the derive class is created and used to access the data members of both the derived and the base class, but the base class can also be acted as an independent class , but the condition is that it should not be the child class of any other card.

  5. #5
    Join Date
    Apr 2009
    Posts
    569

    Re: Which class should be instantiated in from base or derived class ?

    You can create the instance of a derived class with the help of a new keyword, the object of a derived class can be created , this object can be used then to access the members of the child and the parent class .
    Code:
    Class A 
    
    {
     ---members of Class A 
    
    ------methods of class A 
    
    }
    
    
    Class B : A 
    
    {
    ---members of Class A 
    
    ------methods of class A 
    }
    
    Class test 
    
    {
    
    public static void main()
    B b = new B();
    
    b. methods
    b.members
    
    
    }

Similar Threads

  1. Using sizeof () class with empty base class in GCC
    By Alfiee in forum Software Development
    Replies: 6
    Last Post: 27-06-2011, 10:31 AM
  2. Event handlers vs. base class method overrides
    By Tailapa in forum Software Development
    Replies: 5
    Last Post: 26-06-2011, 07:38 PM
  3. Compiling error C2504: Base class undefined
    By vISHaTAN in forum Software Development
    Replies: 6
    Last Post: 26-06-2011, 07:35 PM
  4. What is Visual base class in C++?
    By Venugopala in forum Software Development
    Replies: 4
    Last Post: 28-12-2010, 08:11 AM
  5. Replies: 5
    Last Post: 12-02-2010, 06:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,531,520.16610 seconds with 17 queries