Nested Classes or Inner classes in c++
This video tutorial explains the concept of nested classes or inner classes in c++ programming.
You will learn what is a nested class, how to define a nested class, how to access the members of nested class, what is the scope of the nested class in detail with example.
source code for this tutorial
#include <iostream>
#include <string>
using namespace std;
class Person{
public:
string name;
class Address{
public:
string country;
string stname;
int hno;
};
Address addr;
void AddressPlease(){
cout<< name <<endl << addr.country <<endl <<addr.stname << endl <<addr.hno <<endl;
}
};
int main()
{
Person :: Address ad;
Person anil;
anil.name = "anil";
anil.addr.country = "India";
anil.addr.stname = "madamakki";
anil.addr.hno = 68;
anil.AddressPlease();
return 0;
}