Hi there
I am attempting to modify some code for my own purposes but am finding things tricky as the code is not so well documented with a lot a custom types. As I put things below you should hopefully build a better picture of what I am trying to do.
I have what looks like the following set up.
1. Create a existence of a class based on what appears in a text file. Call this class, class SpecialistType. There are a number of classes that can be instantiated here. Now class SpecialistType inherits class BType. i.e. we have the following sort of definition:
Code:
class SpecialistType : public BType {
2. We also have a B class which is instantiated later on in the program. One of the variables passed to it on start-up what looks like a pointer of BType.
3. Later on the methods in B class are executed.
For example:
Code:
class B {
public:
B(.., .., ..., BType* bt)
Now, because each class does something but is related, I want to put some logic in the code that decides what to do depending on the earlier instantized SpecialistType class.
However I now want to figure out from bt, which type of SpecialistType we have already instantiated. I just don't know if there is anyway to do this, given that we cannot read from the text file anymore.
No I could prob do this by putting some extra fields in some of these classes - but I'd like to make minimum changes to the code. This might seem a silly question, but is there any way I can get a handle on what class was instantiated? Or is it an extra field in BType?
Thanks in advance.