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