What is structure in C++?
- The C++ programming technique allows defining user defined datatypes through the structure.
- It is used to represent a record.
- The 'struct' keyword is used for declaring a structure.
Syntax:struct student
{
//declaration of structure member;
};
Example:struct student
{
char name[100];
char address[250];
};
- Structure always ends with a semicolon ( ; ).
- Accessing any member of a structure, we use the method access operator ( . ).
Example:int main()
{
student s1; //Declaring object of type student
cout<<"Student Name :"<<s1.name;
cout<<"Student Address :"<<s1.address;
}