Structure is a collection of variable of different types under a single name for better visualization of problem. Array is also collection of data but array can hold only one type whereas structure can hold one or more datatypes. Additional functionality given by C++ is, we can write function is structure.
e.g: WAP for structure#include<iostream.h> #include<conio.h> #include<string.h> struct Person{ char name[20]; int age; float salary; void set(char *name,int age,float salary) { strcpy(this->name,name); this->age=age; this->salary=salary; } void show() { cout<<"\n Name = "<<name; cout<<"\n Age = "<<age; cout<<"\n Salary = "<<salary; } }; void main() { clrscr(); Person p; p.set("Ashish",24,20000); p.show(); getch(); }O/P
Name = Ashish Age = 24 Salary =20000