Initialization of Structure
#include <stdafx.h>
#include <iostream>
#include <string>
using namespace std;
/* Initialization of structure members. */
struct Student
{
int roll_no;
string name;
int mark;
}s={10,"AAA",90}; /* This is the way by which we initialize strcture members. */
int main()
{
cout<< "Roll number:" <<s.roll_no <<endl;
cout<< "Name:" <<s.name <<endl;
cout<< "Mark:" <<s.mark <<endl;
return 0;
}
Output:
Roll number:10
Name:AAA
Mark:90