diff --git a/oop/cpp/classesandobjects/README.md b/oop/cpp/classesandobjects/README.md index 7fbed3a..a70dade 100644 --- a/oop/cpp/classesandobjects/README.md +++ b/oop/cpp/classesandobjects/README.md @@ -24,6 +24,7 @@ class Car { string model; int year; + public: // Constructor Car(string color, string make, string model, int year) { this->color = color; @@ -39,7 +40,7 @@ class Car { cout << "Car Year: " << year << endl; cout << "Car Color: " << color << endl; } -} +}; ``` - **Attributes**: The class `Car` has four attributes that describe its state: `color`, `make`, `model`, and `year`. - **Constructor**: The constructor `Car(string color, string make, string model, int year)` initializes new objects of the class. @@ -65,9 +66,11 @@ int main() { car1.displayInfo(); cout << "-----------------"; car2.displayInfo(); + + return 0; } ``` 1. **Instantiation**: The `Car` constructor is used to create an object, which allocates memory for it. 2. **Initialization**: The constructor (`Car`) initializes the object state with given parameters. -3. **Reference**: The object is referenced through a variable (`car1`, `car2`) that points to its memory location. \ No newline at end of file +3. **Reference**: The object is referenced through a variable (`car1`, `car2`) that points to its memory location.