Initial commit
This commit is contained in:
29
cpp/Классы/main.cpp
Normal file
29
cpp/Классы/main.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
string name = "Cat";
|
||||
|
||||
// Объявление класса
|
||||
class MyClass {
|
||||
public:
|
||||
int myNum;
|
||||
string name;
|
||||
|
||||
string str() {
|
||||
return name;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
// Создание объекта
|
||||
MyClass myObj;
|
||||
|
||||
// Доступ к атрибутам
|
||||
myObj.myNum = 5;
|
||||
myObj.name = "Vincent";
|
||||
|
||||
cout << myObj.str() << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user