42cpp-module-05
ex03
- 同じ base class からできた複数個の derived class に1つのメソッドから使用できるようにする
- メソッドポインタを使用する
- new 演算子を使用する
ex02
- 同じ base class からの複数個の derived class
- オーバーライドしたメソッドを両方使用する
- derived class のオーバーライドしたメソッドの中でも base class のオーバーライドしたメソッドを呼べる
ex01
- 複数個の exception
- 上手にエラーハンドリング
- nested classes
- その13 内部クラスは外側クラスのメンバにアクセスし放題!
- そろそろ内部クラスに関して一言言っておくか
#include <iostream> class Hoge { public: Hoge() : bar_(*this) {} private: class Bar { public: explicit Bar(Hoge& hoge) : hoge_(hoge) {} void func() { hoge_.func(); } Hoge& hoge_; }; Bar bar_; void func() { std::cout << "func" << std::endl; } public: Bar& Bar() { return bar_; } }; int main() { Hoge hoge; hoge.Bar().func(); return 0; }
- Why would one use nested classes in C++?
- Why is a type qualifier on a return type meaningless?
ex00
- std::exception
exception
クラスは,標準ライブラリが提供する全ての例外クラスの基底クラス.
- nested classes
- Static constant string (class member)
- Before C++17
// *.hpp class A { private: static const string RECTANGLE; }; // *.cpp const string A::RECTANGLE = "rectangle";
- After C++17
// *.hpp class A { private: inline static const string RECTANGLE = "rectangle"; };
- Before C++17
- Weird error on 'exception specification of overriding function is more lax than base version' in C++
- exception specification of overriding function is more lax than base version