If I create a class called "tree" and inherit from it to classes called "elm" and "oak", can I, using all three header files, create a vector <tree> and use push_back to add an "elm" and an "oak" to that vector?
venomlash
55
Junior Poster
Recommended Answers
Jump to PostWhy don't you write a simple code snippet and see? If the compiler doesn't complain, then it should be allowed.
Jump to PostTry making a vector of Tree*, and add elements which are Oak* and Elm*. Of course, this means you'll be working with pointers, but I'm assuming that you'll be fine with that...
All 8 Replies
WolfPack
491
Posting Virtuoso
Team Colleague
venomlash
55
Junior Poster
Infarction
503
Posting Virtuoso
Narue
5,707
Bad Cop
Team Colleague
venomlash
55
Junior Poster
Infarction
503
Posting Virtuoso
John A
1,896
Vampirical Lurker
Team Colleague
Narue
5,707
Bad Cop
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.