(46) 21.1 Object Oriented Programming in CPP. - anishsingh90/Data_Structure_And_Algorithm_In_Cpp_github.io GitHub Wiki

#include <bits/stdc++.h> using namespace std;

class Student{ public: string name; int age; bool gender;

void printInfo(){
	cout << "Name: ";
	cout << name << endl;
	cout << "Age: ";
	cout << age << endl;
	cout << "Gender: ";
	cout << gender << endl;
}

};

int main(){ Student arr[3]; for(int i=0; i<3; i++){ cout << "Name : "; cin >> arr[i].name; cout << "age: "; cin >> arr[i].age; cout << "gender: "; cin >> arr[i].gender; }

cout << endl;
cout << "Print the outPut: "<< endl;
for(int i=0; i<3; i++){
	arr[i].printInfo();
}
return 0;

}

/* OUTPUT: Name : Anish age: 20 gender: 0 Name : Manish age: 30 gender: 1 Name : Sahil age: 32 gender: 0

Print the outPut: Name: Anish Age: 20 Gender: 0 Name: Manish Age: 30 Gender: 1 Name: Sahil Age: 32 Gender: 0 */