Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- class Student {
- public:
- int grade; ///класс -- поля
- int age; ///возраст
- string name; //имя
- double score; //оценка
- void hi() {
- cout << "Привет, я " << name << ", мне " << age << " лет!\n";
- }
- int solve(int a, int b) {
- return a + b;
- }
- };
- int main() {
- Student vasya;
- vasya.age = 15;
- vasya.grade = 8;
- vasya.name = "Vasya";
- vasya.score = 5;
- vasya.hi();
- Student petya;
- petya.age = 12;
- petya.grade = 6;
- petya.name = "Petya";
- petya.hi();
- petya.score = 3;
- cout << petya.age << ' ' << vasya.age << '\n';
- int x = petya.solve(2, 3);
- cout << x;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement