Yes this is possible, but you still need an instance of that inner class to work with. In your case, you could do:
Code:
first::second mySecond;
mySecond.b = 5;
Another common nested class is an iterator. Here's a short example of something you might see:
Code:
class List
{
public:
class iterator
{
//...
};
//common member functions
iterator begin();
iterator end();
};
int main()
{
List myList;
//do some insertions into the list
//declare an iterator and initialize it to the beginnning of the list
List::iterator it = myList.begin();
}
A few more things I should point out (and you'll hear these a lot if you keep reading the forums):
1. You're using non-standard headers. The appropriate headers are:
Code:
#include <iostream>
#include <cstdio>
There is no standard equivalent of conio.h, so you might want to consider using another method of pausing the program at the end.
2. void main is not standard. Use int main. Note that you do not have to explicitly return a value from main (it will implicitly return 0), though it might be considered good practice.
3. Member data of classes should always be private. You might've just made your variables public for simplicity, but I thought I should note it anyway