Below is my class where I'm inheriting a class that has a nested class within it. The CMethod0173 is basically duplicating CMethod172, and is one of my first attempts at utilizing the re-usability aspects of inheriting classes. I want to override the parent's CMethod172::Args::getArgs(AlignArgs*args); function by having it call the parent class and then do it's own thing. Below that are some things I tried that didn't work.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#ifndef CMETHOD0173_H
#define CMETHOD0173_H
#include"CMethod0172.h"
class CMethod172;
class CMethod0173 : public CMethod172
{
public:
CMethod0173(AlignArgs *args);
class Args
{
public:
void getArgs(AlignArgs *args);
};
private:
};
#endif /* CMETHOD0173_H */
This didn't work because it has to be an instance variable. I suppose I could fix this with a static function if it didn't need to be an instance because of inherited data. I'm not showing the inherited class for simplicity because it's referencing hundreds of classes that I would have to show for it to make any sense. Anyway, it has data in it that it tracks throughout each instance, so static isn't really an option for the re-usability concept because I would then have to go re-write it to all track things somewhere else. Anyway, I tried this next:
This didn't work because of the error that the qualified name "CMethod172::Args::getArgs(args);" is not a member of class "CMethod0173::Args" or its base classes. I hate to admit that I know this, but in objective C I would just call [super getArgs:args] (if that were the language/syntax) in order to reference the parent. Is there a way to do this in C++?
Thanks,
Sean
Right, maybe in objective C it's "super" or something that references the base class generically. If this weren't nested, I could just call the this->CMethod0173.getArgs(some_args); to distinguish from this->CMethod172.getArgs(some_args);
Thus, somehow I need to go back into the nest or reference the parent or super class generically, if there is a way to do it. I also tried:
1 2 3 4 5
void CMethod0173::Args::getArgs(AlignArgs *args)
{
using CMethod172::Args::getArgs(AlignArgs *args);
getArgs(args);
}
but it said that a class qualified name, CMethod172::Args::getArgs(AlignArgs*args); was not allowed, starting at the CMethod172...