View Single Post
Old 07-31-2005, 01:41 PM   #1 (permalink)
Aniviel833
Registered User
 
Join Date: Jun 2005
Posts: 26
Aniviel833 is on a distinguished road
Inheritance and Constructors

Hey all,

I'm having some problems with my constructors. I have a base class and an inherited class. How do constructors work in this situation?

I've tried writing a seperate constructor for my inherited class, but it wouldn't recognize any of the variables from the base class. (But functions in the inherited class would.) So then I created the same variables in the inherited class as I had in the base class. (Yeah, yeah... ) But, unsurprisingly, the constructor still doesn't work. Everything compiles fine, but if I try and create a new object of type MyInheritedClass, The object is created with the default constructor from the base class.
</stupidity>

So, if someone could point me towards a tutorial addressing this, or explain it, I'd appreciate it.

(Or shall I post the code? Is this a situation where it should work but I've written some really stupid code?)

Also, would someone recommend a new book to me? My 'Beginner' books don't address lots of things like this, (they minimally address classes, inheritance, and constructors, but don't really show how they work in many situations like this...) yet I'm still very much a noob.

Thanks!
-Stacy
Aniviel833 is offline   Reply With Quote