编译器 以及 纯虚函数

突然发现人生 完全没意义了

#include 

#include 

class Base
{
public:
    Base(){printf("BaseContor\n");foo();}
    ~Base(){printf("BaseDeContor\n");foo();}
    virtual void foo()=0{printf("Base foo\n");}
};

class Derive:public Base
{
public:
    Derive(){printf("DeriveContor\n");foo();}
    ~Derive(){printf("DeriveDeContor\n");foo();}
    virtual void foo(){printf("Derive foo\n");}
};

int main()
{
    Base* b=new Derive();
    getchar();
    delete b;
    return 0;
}

结果:

gcc version 4.4.1 (TDM-2 mingw32) g++
    error: pure-specifier on function-definition
vs2005
    compile  it successful
    output:
        BaseContor
        Base foo
        DeriveContor
        Derive foo

无语了!!!

你可能感兴趣的:(奇葩)