wilson_wilson:
Hey Guys
I have two subclasses with lots of the same functions and I would like to call a series of same functions from both classes, the simplest example of what I would like to do is below (btw I use "virtual" to ensure the sub-base function is prioritized over superclass function!)
Not sure what you wanted to ask, as you did not place any question. But in case you want to copy the object to another type, the inheritance must be public, and a copy constructor for that type would be necessary.
Ex Ovo Omnia:
Not sure what you wanted to ask, as you did not place any question. But in case you want to copy the object to another type, the inheritance must be public, and a copy constructor for that type would be necessary.
Not sure what you wanted to ask, as you did not place any question. But in case you want to copy the object to another type, the inheritance must be public, and a copy constructor for that type would be necessary.
is there a way to use a "generic" pointer or generic subclass that gets assigned a different subclass on each iteration ? I prefer not to explicitly do copy constructor as the two subclass objects already exist and I prefer not to write many more lines of code.
Use pointers - then you'll have no need to copy objects and implement copy constructors. Pointer of base type can hold actual pointers to objects of derived classes.
Stanislav Korotky:
Use pointers - then you'll have no need to copy objects and implement copy constructors. Pointer of base type can hold actual pointers to objects of derived classes.
Use pointers - then you'll have no need to copy objects and implement copy constructors. Pointer of base type can hold actual pointers to objects of derived classes.
yep, base class pointer did the trick :)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hey Guys
I have two subclasses with lots of the same functions and I would like to call a series of same functions from both classes, the simplest example of what I would like to do is below (btw I use "virtual" to ensure the sub-base function is prioritized over superclass function!)