| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 715. Range Module
- LeetCode
- shiba
- 프로그래머스
- data science
- 파이썬
- iterator
- Python Code
- 30. Substring with Concatenation of All Words
- 컴퓨터의 구조
- 43. Multiply Strings
- 315. Count of Smaller Numbers After Self
- Class
- 운영체제
- t1
- concurrency
- 시바견
- Python
- 109. Convert Sorted List to Binary Search Tree
- Substring with Concatenation of All Words
- 밴픽
- Regular Expression
- attribute
- Protocol
- Convert Sorted List to Binary Search Tree
- Decorator
- DWG
- Generator
- kaggle
- Python Implementation
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++] Regular Expression Matching (0) | 2024.09.26 |
|---|---|
| [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 |