Design question for using derived class/ Multiple Base classes
-
Thankx I think I am ready to code.... After being a Dinasour Assembler programmer for 30 years writting procedurel code its hard to change my way thinking
Have fun! I coded a few years in assembler and C before C++, but not 30 :) Thinking in terms of classes will be second-nature in no time. Cheers, MArk
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Have fun! I coded a few years in assembler and C before C++, but not 30 :) Thinking in terms of classes will be second-nature in no time. Cheers, MArk
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
1slipperyfish wrote:
why wouldn't you inherit?
You are just not following the thread. Your post used classes "Animal" and "Dog" which provide "context" and obviously a Dog "is a" Animal thereby indicating inheritance. However, the original poster used the classes "A" and "B" which provide no context and therefore we cannot distinguish between "is a" or "has a". By the way Mark wants to have lunch with you.
i thought that was what was happening and wondered why use A and B?? i am only a learner myself:-O i am on leave all week so any day suits me:-D paul
if ignorance is bliss then knock the smile off my face!!!
-
I understand I am going say something to see if I undertand what you mean a typical way of altering functionality would be to declare a method as Virtual that way the derived class can implement Its version of the method Or Since dervied members can have thier version of the Base('s) constructer that would be a way of altering the functionality
Puncuation of some sort would extremely help in getting your ideas across.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal.
George Orwell, "Keep the Aspidistra Flying", Opening words -
Puncuation of some sort would extremely help in getting your ideas across.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal.
George Orwell, "Keep the Aspidistra Flying", Opening words -
can i add a quetion on the end? i have a base class animalClass.hpp i have a derived Dog class and main in dogObj.cpp and a derived Cat class in catObj.cpp what i wanted to know is should i have animalClass.hpp dogClass.hpp, catClass.hpp, declaring the classes and have a seperate animalObj.cpp for main() to constrol the functions etc? at the moment my animalClass is about fifty lines as are the other animal classes, with my main () about 80 lines thanks in advance paul
if ignorance is bliss then knock the smile off my face!!!
-
can i add a quetion on the end? i have a base class animalClass.hpp i have a derived Dog class and main in dogObj.cpp and a derived Cat class in catObj.cpp what i wanted to know is should i have animalClass.hpp dogClass.hpp, catClass.hpp, declaring the classes and have a seperate animalObj.cpp for main() to constrol the functions etc? at the moment my animalClass is about fifty lines as are the other animal classes, with my main () about 80 lines thanks in advance paul
if ignorance is bliss then knock the smile off my face!!!
1slipperyfish wrote:
should i have animalClass.hpp dogClass.hpp, catClass.hpp, declaring the classes and have a seperate animalObj.cpp
you need header files (.h, .hpp) if you want to use the classes in other .cpp files so they can be #include < ...> If the class is defined in a cpp file the visibility of it is limited to (not sure) that file maybe.
-
1slipperyfish wrote:
should i have animalClass.hpp dogClass.hpp, catClass.hpp, declaring the classes and have a seperate animalObj.cpp
you need header files (.h, .hpp) if you want to use the classes in other .cpp files so they can be #include < ...> If the class is defined in a cpp file the visibility of it is limited to (not sure) that file maybe.
thanks for the reply led mike :D i have rewritten my classes into baseClass.hpp, CatClass.hpp, and DogClass.hpp with farms.cpp initialising the functions and having main() i had a lot of trouble compiling as it kept saying i had already declared my Mammal class in baseClass however if you add [code]#ifndef BASE_CLASS_HPP #define BASE_CLASS_HPP[/code] at the top of baseClass.hpp and [code]#endif[/code] at the bottom it works. you all probably already new that but i've just wasted 2 1/2 hours of my life learning that the hard way:D thanks again paul
if ignorance is bliss then knock the smile off my face!!!
-
can i add a quetion on the end? i have a base class animalClass.hpp i have a derived Dog class and main in dogObj.cpp and a derived Cat class in catObj.cpp what i wanted to know is should i have animalClass.hpp dogClass.hpp, catClass.hpp, declaring the classes and have a seperate animalObj.cpp for main() to constrol the functions etc? at the moment my animalClass is about fifty lines as are the other animal classes, with my main () about 80 lines thanks in advance paul
if ignorance is bliss then knock the smile off my face!!!
MAybe I shouldn't answer this after all I work as a MainFrame Assembler Dino programmer I think think if you declare it in the code/obj/cpp you just have to qualify the method with Class name e.g. DogClass :: dogmethod saying that this dogmethod is releated to the dogalass Class Trying to get into the future.....
-
MAybe I shouldn't answer this after all I work as a MainFrame Assembler Dino programmer I think think if you declare it in the code/obj/cpp you just have to qualify the method with Class name e.g. DogClass :: dogmethod saying that this dogmethod is releated to the dogalass Class Trying to get into the future.....
thanks paul
if ignorance is bliss then knock the smile off my face!!!