What is structure in C++?

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;
}
What is reference variable in C++?
What is reference variable in C++? - A reference variable is just like pointer with few differences...
What is class using C++?
Class using C++ - A class holds the data and functions that operate on the data....
What is local class in C++?
Local class in C++ - Local class is define within the scope of a function and nested within a function...
Post your comment
Discussion Board
Missing semicolons
There is no semicolons at the end. It may seem obvious but I think it is worth mentioning.
Bartek 08-27-2015