Nested Structures and using dot operator with Nested Structures




This video tutorial explains the nested structures in c++.
You will learn what is a nested structure, how to create a nested structure, what is the use of nested structure,how to define nested structure,how to create the variables using nested structure, how to access the members of a nested structure using dot operator in detail with example.

source code for this tutorial

#include <iostream>
#include<string>

using namespace std;

struct address{
    int house_no;
    string street_name;
};

struct student{
    string name;
    int rollno;
    address addr;
};

int main()
{
student anil;

anil.name = "anil";
anil.rollno = 1234;

anil.addr.house_no = 60;
anil.addr.street_name = "m g road";

cout << anil.name<<endl;
cout << anil.rollno<<endl;

cout << anil.addr.house_no<<endl;
cout << anil.addr.street_name<<endl;

    return 0;
}