Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##### [11:08:10] # [dare2be@PC10CIS:/tmp] #####
- $ cat b.cpp
- class B {
- public:
- B() { f1(); }
- // call from ctor to “impure” virtual; looks safe
- virtual void f1() { f3(10); } // call to pure virtual from non-ctor; looks safe
- virtual void f3(int x) = 0;
- };
- class D : public B {
- void f3(int x) {}
- };
- int main() {
- D d;
- return 0;
- }
- ##### [11:08:24] # [dare2be@PC10CIS:/tmp] #####
- $ g++ -Wall b.cpp -o b
- ##### [11:08:35] # [dare2be@PC10CIS:/tmp] #####
- $ ./b
- pure virtual method called
- terminate called without an active exception
- Aborted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement