AllExperts > Object Oriented Programming 
Search      
Object Oriented Programming
Volunteer
Answers to thousands of questions
 Home · More Object Oriented Programming Questions · Answer Library  · Encyclopedia ·
More Object Oriented Programming Answers
Question Library

Ask a question about Object Oriented Programming
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Marty Landman
Expertise
Available for questions involving packaging, writing and using methods, and generally most object oriented techniques. Conversion from modular (routine based) to OOP (object based) is a pet interest of mine. My language experience in this area is (in order of competence) Perl C++ PHP Visual Basic/ASP Java

Experience
Programmer since 1980, web developer since 1998.

Education/Credentials
M.S. in Computer Science from New York University

 
   

You are here:  Experts > Computing/Technology > Perl/PHP > Object Oriented Programming > inheritance and superclass instance

Object Oriented Programming - inheritance and superclass instance


Expert: Marty Landman - 2/6/2006

Question
Hi,

With the following snippet, how many objects of type A are created? I know for sure there is one in line #4, but is there another object of type A created in line #5 as well?

Thanks, lzzzz
-------------------------------
class A {};

class B : public A {};

int main() {
A a = new A(); // line #4
B b = new B(); // line #5
}
------------------------------

Answer
Iz,

The easiest way to find the answer is for you to put a print stmt like sprint or AfxMessageBox or whatever will work for your development environment.

Put the print stmt into the class A object constructor method, and you'll see what's happening. This will be more instructive than my just telling you.


Marty Landman, Face 2 Interface Inc.
Webmaster's Bulletin Board: http://bbs.face2interface.com/
Web Installed Formmail: http://face2interface.com/formINSTal

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.