Categories: C++Learn C++

Nested Structure|Structure within Stucture in C++

Nested structure |Structure within Structure in C++

In this tutorial, we will discuss the Nested Structure|Structure within Structure in C++ language

A structure is a complex data type in C++. Structure can contain basic data types of C++. int, float, char, double, etc..

Nested structure is when a structure is contained inside another one.

Syntex

Syntex of the nested structure in C++ language

Example

Example of the nesting structure in C++ language

Example program

The program has two structures named school and student. The structure school contains two variables sch_Name, sch_id. Student structure contains four variable stu_id,  stu_name, marks, Avg and also the structure address of school with that object.

So school structure can be accessed from inside the student structure.

Program 1

Output

Program 2

Output

 

In this program, Name, Emp_no, joint date of an employee are declared inside employee structure, while joint date is another structure which contains dd, mm,yyyy variable to read joint date. 
we use Joint_date structure inside employee structure

 

Related Post

Structure in C Language                                       Structure in C++ Language
Function in C Language                                           Nested structure  in C access with variable           

 

 

Karmehavannan

Recent Posts

Multiply two numbers in Java using scanner| 5 different ways

Multiply two numbers in Java using scanner| 5 different ways In this article, we will…

3 months ago

5 different ways to Divide two numbers in Java using scanner

5 Different ways to Divide two numbers in Java using scanner In this article, we…

3 months ago

Learn 8 Ways to Subtract Two Numbers Using Methods in Java

Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…

4 months ago

10 ways to subtract two numbers in Java

10 ways to subtract two numbers in Java In this article, we will discuss the…

4 months ago

Java Code Examples – Multiply Two Numbers in 5 Easy Ways

Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…

4 months ago

How to Divide two numbers in Java| 5 different ways

How to Divide two numbers in Java| 5 different ways In this article, we will…

4 months ago

This website uses cookies.