| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- Python
- DWG
- t1
- 30. Substring with Concatenation of All Words
- kaggle
- 43. Multiply Strings
- Python Implementation
- data science
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- 315. Count of Smaller Numbers After Self
- 프로그래머스
- concurrency
- 715. Range Module
- LeetCode
- 시바견
- Generator
- Substring with Concatenation of All Words
- Convert Sorted List to Binary Search Tree
- 컴퓨터의 구조
- Class
- shiba
- Python Code
- Protocol
- 운영체제
- 밴픽
- Regular Expression
- iterator
- attribute
- 파이썬
Archives
- Today
- Total
Scribbling
[C++] Interface 본문
#include <iostream>
using namespace std;
class Printable {
friend ostream& operator<<(ostream& os, const Printable& obj);
public:
virtual void print(ostream& os) const = 0;
virtual ~Printable() {}
};
ostream& operator<<(ostream& os, const Printable& obj) {
obj.print(os);
return os;
}
class class1 : public Printable {
public:
virtual void print(ostream& os) const override {
os << "class1" << endl;
}
};
class class2 : public Printable {
public:
virtual void print(ostream& os) const override {
os << "class2" << endl;
}
};
int main() {
class1 cls1;
class2 cls2;
cout << cls1 << endl;
cout << cls2 << endl;
}'Computer Science > C++' 카테고리의 다른 글
| [C++] LRU Cache (2) | 2024.10.05 |
|---|---|
| [C++] Object Oriented Programming (0) | 2024.10.01 |
| [C++] Strings (0) | 2024.09.30 |
| [C++] Abstract Class, Polymorphism (0) | 2024.09.28 |
| [C++] Virtual Functions (0) | 2024.09.28 |