Introduction to Structures in c++





This video tutorial explains the concept of structures in c++.
You will learn what is a structure, how to define a structure, how to declare the variables of a structure, how to assign values to structure variables using dot operator, how to access values from structure variables using dot operator in detail with examples.


source code for this tutorial

#include <iostream>

using namespace std;

struct student{
    int rollno;
    char sex;
}anil,rashmith;

int main()
{
    student rahul,ajay = {1111,'m'};

    rahul.rollno = 2222;
    rahul.sex = 'm';

    anil.rollno = 8888;
    anil.sex = 'm';

    rashmith.rollno = 2222;
    rashmith.sex = 'm';

    cout << anil.rollno << endl << anil.sex <<endl;
    return 0;
}

Back To Top