C++ - Day - 6 - Basic About OOP
C++ - Day - 6 - Basic About OOP
▪ What is Class
▪ What is object
▪ How to declare a class
▪ How to implement class
class Dog {
▪ Properties:
public:
• Name
void eat();
• Age void sleep();
• Color void run();
• Weight void bark();
▪ Activities: private:
string mName;
• Eat
int mAge;
• Sleep string mColor;
• Run int mWeight;
• Bark };
int Rectangle::getArea() {
return mWidth*mHeight;
}
▪ What is Encapsulation?
▪ Benefit?
▪ All member variables of the class are made private (hiding the
implementation details), and most member functions are made
public (exposing an interface for the user)
class Rectangle {
private:
int mWidth;
int mHeight;
public:
void setValues(int, int);
int getArea(void);
};
▪ Constructors
▪ Copy constructor
▪ Destructors
▪ https://www.tutorialspoint.com
▪ https://www.learncpp.com/
▪ 4 characteristics of OOP
▪ What is Class and Object
▪ Data encapsulation
▪ Public, Private, Protected
▪ Constructors, Copy constructor, Destructors