Lec#01
Lec#01
}
example
class Car {
public:
string brand;
string model;
int year;
void startEngine() {
// ...
}
};
int main() {
Car myCar;
Car friendCar;
// ...
}
Activity
Activity Title: Exploring Classes and
Objects with a Simple Calculator
Introduction:
Class Design:
After each operation, you will call the appropriate member function to display
the results.
Classes and
Objects
An object is said to be an instance of a class
Constructor
using namespace std;
class emp {
private:
{
emp xx (234, 56789.90);
xx.disp();
system("pause");
int empid;
return 0;
float pay;
}
public:
//parameterized constructor
emp(int a, float pp)
{
empid=a;
pay=pp;
}
void disp()
{
cout<<" Employee ID = "<<empid<<"\n\n"<<"Pay "<<pay<<endl;
}
};
The name of the destructor is the same as the name of the class,