-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2-classes_objects.cpp
32 lines (22 loc) · 1.01 KB
/
2-classes_objects.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <string.h>
using namespace std;
// Classes simplt
class Car { // Class declare
public: // Access modefire
string name; // Class attributes (in c++ variables means attributes)
string model; // Class attributes (in c++ variables means attributes)
int price; // Class attributes (in c++ variables means attributes)
};
int main() {
Car Hyundai; // new object declare
Hyundai.name = "creta"; // Set attributes to the class attributes
Hyundai.model = "alpha"; // Set attributes to the class attributes
Hyundai.price = 150; // Set attributes to the class attributes
// Printing the class attributes
cout << "The name of car is: " << Hyundai.name << endl;
cout << "The model ofc car is: " << Hyundai.model << endl;
cout << "The price of car is: " << Hyundai.price << endl;
system("pause");
return 0;
}