-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass.cpp
More file actions
42 lines (33 loc) · 719 Bytes
/
Copy pathclass.cpp
File metadata and controls
42 lines (33 loc) · 719 Bytes
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
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <string>
using namespace std;
class Person {
public:
string name;
int age;
void introduce() {
cout << "Hi, I am " << name << " and I am " << age << " years old.\n";
}
};
class Book {
public:
string title;
string author;
double price;
void showInfo() {
cout << "Book: " << title << " author: " << author << " price: " << price << "\n";
}
};
int main() {
Book b1;
b1.title = "test";
b1.author = "test";
b1.price = 19.99;
b1.showInfo();
Book b2;
b2.title = "test2";
b2.author = "test2";
b2.price = 20.00;
b2.showInfo();
return 0;
}