C++ Program to show usage of classes and objects
Program
#include<iostream>
using namespace std;
class A
{
public:
int i, j, k;
};
int main()
{
A a, b;
a.i = 100;
a.j = 5;
a.k = a.i * a.j;
cout << "This is from object a of class 'A' " << a.k << endl;
b.i = 9;
b.j = 10;
b.k = b.i + b.j;
cout << "This is from object b of class 'A' " << b.k << endl;
return 0;
}
Output
This is from object a of class 'A' 500
This is from object b of class 'A' 19