zoukankan      html  css  js  c++  java
  • 链接时报错:undefined reference to vtable 原因以及解决办法

    如果一个虚函数不是纯虚函数,父类需要实现它。否则就会报错:undefined reference to vtable XXX
    例如:
    class a
    {
    public:
         virtual bool fun();
    }
    class b:public a
    {
         virtual bool fun(){cout << "I am b"  << endl;}
    }
    以上代码编译时会报错undefined reference to vtable XXX

    修改为:
    class a
    {
    public:
         virtual bool fun(){cout << "IamA" << endl;};
    }
    class b:public a
    {
         virtual bool fun(){cout << "I am b"  << endl;}
    }
  • 相关阅读:
    11
    TSP-test
    TSP-SA_TSP
    TSP-PathLength
    TSP-OutputPath
    TSP-NewAnswer
    TSP-
    TSp-dsxy2figxy
    TSP-DrawPath
    TSP-Distanse
  • 原文地址:https://www.cnblogs.com/nickchan/p/3104478.html
Copyright © 2011-2022 走看看