C++- typedef as a class alias and integer alias

Objective:

  • using typedef as a class alias
  • using typedef as an integer  alias

Step : 1 Create a new project

Step: 2 Edit the codes

#include <iostream>
#include <stdio.h>
using namespace std;
typedef class size {
public: int Phy;
public: int Chem ;
public: int total;
} limit;
int main()
{
typedef int class_size;

class_size Physics, Chemistry, Total, total;
cout << "Enter the number of students.\n";
cout << "Physics: ";
cin >> Physics;
cout << "Chemistry: ";
cin >> Chemistry;
Total = Physics + Chemistry;

cout << "\nNumber of students:";
cout << "\n No. of Students in Phyics: " << Physics;
cout << "\n No. of Chemistry: " << Chemistry << "\n";
cout << "\n Total No. of Students: " << Total << "\n";
limit seatlimit;
seatlimit.Chem = 30;
total = seatlimit.Chem - Chemistry;
cout << "seat remains in Chemistry Class "<< total ; //
return 0;
}
 

Step: 3 runt time view