일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 43. Multiply Strings
- concurrency
- 315. Count of Smaller Numbers After Self
- 프로그래머스
- Generator
- 파이썬
- 운영체제
- LeetCode
- 시바견
- Substring with Concatenation of All Words
- Python
- shiba
- 109. Convert Sorted List to Binary Search Tree
- Protocol
- 밴픽
- iterator
- Python Code
- data science
- 715. Range Module
- 30. Substring with Concatenation of All Words
- attribute
- 컴퓨터의 구조
- kaggle
- DWG
- Class
- Decorator
- Convert Sorted List to Binary Search Tree
- t1
- Python Implementation
- Regular Expression
Archives
- Today
- Total
Scribbling
[C++] Abstract Class, Interface, Multiple Inheritance 본문
Computer Science/C++
[C++] Abstract Class, Interface, Multiple Inheritance
focalpoint 2024. 2. 14. 07:18using namespace std;
class Shape {
public:
virtual void roar() = 0;
virtual ~Shape() {};
};
class I_Shape {
public:
friend ostream &operator<<(ostream &, const I_Shape &obj);
virtual void print(ostream &os) const = 0;
virtual ~I_Shape() {};
};
ostream &operator<<(ostream &os, const I_Shape &obj) {
obj.print(os);
return os;
}
class Circle : public Shape, public I_Shape {
public:
virtual void roar() override {
cout << "Circle" << endl;
}
virtual void print(ostream &os) const override {
os << "This is Circle" << endl;
}
virtual ~Circle() {};
};
int main() {
Circle cir = Circle();
Shape& obj = cir;
obj.roar();
I_Shape &i = cir;
cout << i;
}
'Computer Science > C++' 카테고리의 다른 글
[C++] Priority Queue with custom data type (0) | 2024.02.22 |
---|---|
[C++] lower_bound (0) | 2024.02.06 |
[C++] Deque<int> (0) | 2024.02.06 |
[C++] 전문가를 위한 C++ - Chapter 8 (0) | 2023.10.07 |
[C++] find, deque, bfs, structured binding (0) | 2023.09.30 |