Home | | Computer Science 11th std | C++: Referencing Structure Elements

Chapter: 11th Computer Science : Chapter 12 : Arrays and Structures

C++: Referencing Structure Elements

Once the two objects of student structure type are declared (balu and frank),their members can be accessed directly.

Referencing Structure Elements

 

Once the two objects of student structure type are declared (balu and frank),their members can be accessed directly. The syntax for that is using a dot (.) between the object name and the member name. For example, the elements of the structure Student can be accessed as follows:

 

balu.rollno

balu.age

balu.weight

frank.rollno

frank.age

frank.weight

If the members are a pointer types then ‘’ is used to access the members. Let name is a character pointer ins student like char * name It can be accessed student name

 

 

(Anonymous Structure Vs Named Structure)

A structure without a name/tag is called anonymous structure.

struct

{

long rollno;

      int age;

      float weight;

} student;

The student can be referred as reference name to the above structure and the elements can be accessed like student.rollno, student.age and student.weight .

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
11th Computer Science : Chapter 12 : Arrays and Structures : C++: Referencing Structure Elements |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.