|
Inherited Classes
Hey,
Do a bass class and subclass have to be in the same header file? The reason I ask is that I have one base class and a few subclasses and when I try to put each of them in their own header it doesnt work. For example:
Well, I thought something like that would work. SubClass.h includes BaseClass.h, but it still does not know about BaseClass for some reason and I get like 1000 errors. Is there something special I have to do? Or am I stuck with subclasses and base classes being in the same header file? Well, thanks.
Later.
Mmmm, that looks OK to me. You can definitely put them in seperate files (as long as the subclass file #includes the BaseClass header). If you''re getting a million errors, check to make sure you put a semicolon after each class definition, I noticed you didn''t in you''re example. Otherwise, give a sample of the errors you are getting.
Good luck.
Good luck.
Hey,
Thanks, that was the problem. One of my nested classes I forgot to put '';'' at the end. Well now I have another problem. Hopefully its as simple of a solution. I have 2 classes. Base and Sub. Now whenever I try to access a function in the Base Class, that is public, from a Sub class function. I get this error.
[/source]
error C2248: ''Draw'' : cannot access public member declared in class ''GameObject''
[/source]
Now, I thought if I made something public in GameObject, any subclass would be able to use it. Is this not the case? If so, what should I do to make this work?
Thanks
Thanks, that was the problem. One of my nested classes I forgot to put '';'' at the end. Well now I have another problem. Hopefully its as simple of a solution. I have 2 classes. Base and Sub. Now whenever I try to access a function in the Base Class, that is public, from a Sub class function. I get this error.
[/source]
error C2248: ''Draw'' : cannot access public member declared in class ''GameObject''
[/source]
Now, I thought if I made something public in GameObject, any subclass would be able to use it. Is this not the case? If so, what should I do to make this work?
Thanks
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement