Well, just a couple of things you did wrong here.
1). You are using two separate classes, not one inside the other
2). You are (incorrectly) creating a temporary variable inside the constructor.
PS I didn't test this code, and I'm tired so there is most certainly something wrong with it, but it should point you in the right direction (more or less)
Put your class declarations into a header file, and the definitions of their functions into a corresponding .cpp file. To use a variable of a particular type, include it's header file.
Your inttest object only exists within the scope of the constructor. As soon as the program exits the constructor, inttest is destroyed, so it never exists. What you probably want is to store the object as one of mainclass' member variables.
1 2 3 4 5 6 7 8 9 10
class subclass{/*...*/}object;
class mainclass{
public:
unsignedint integerlength;
subclass *inttest; //<-- This is valid code.
mainclass(){
integerlength = 5;
inttest = &object;
}
};
Edit:
Take my example with a grain of salt as I realize that I don't really understand how you want to implement your class within a class, e.g. if you want to create a pointer to the subclass or if you want to create a nested class as other above have mentioned.