如何处理“未解决的外部符号”错误?

时间:2012-11-27 22:03:51

标签: c++

  

可能重复:
  What is an undefined reference/unresolved external symbol error and how do I fix it?

我正在尝试列出指向子类的指针,并尝试使用其他类查找/删除对象

//class product
public:
    static vector<Product*> plist;
    static vector<Product*>::iterator tT;


//class book:public Product 
book::book(string a,double b, string c,string d,string e):Product(a,b,c),
    author(d),publisher(e)
{
    Product *k=this;
    plist.push_back(k);
}



class ProductCatalog:public Product // i really dont know how to implement this friend maybe
{
public:
    ProductCatalog();
    void findproduct(string);
    void deleteproduct();
    void addproduct();
    void listcatalog();

};

void ProductCatalog::findproduct(string temp){

    cin>>temp;
    tT=plist.begin();
    for (tT=plist.begin();tT!=plist.end();tT++){
        if((*tT)->getID()==temp)
            (*tT)->getSummery();
    }
}

void ProductCatalog::deleteproduct(){
    cout<<"enter id to delete"<<endl;
    string dd;
    cin>>dd;
    tT=plist.begin();
    for (tT=plist.begin();tT!=plist.end();tT++){
        if((*tT)->getID()==dd)
            plist.erase(tT);
    }
}

错误

  

1&gt; book.obj:错误LNK2001:未解析的外部符号“public: static class std::vector<class Product *,class std::allocator<class Product *> > Product::plist

     

1&gt; cd.obj:错误LNK2001:未解析的外部符号“public: static class std::vector<class Product *,class std::allocator<class Product *> > Product::plist

     

1&gt; ProductCatalog.obj:错误LNK2001:未解析的外部符号   “public: static class std::vector<class Product *,class std::allocator<class Product *> > Product::plist

     

1&gt; ProductCatalog.obj:错误LNK2019:未解析的外部符号   “public: __thiscall Product::Product(void)”(?? 0Product @@ QAE @ XZ)   在函数“public: __thiscall ProductCatalog::ProductCatalog(void)”中引用

     

1&gt; ProductCatalog.obj:错误LNK2001:未解析的外部符号   “public: static class std::_Vector_iterator<class std::_Vector_val<struct std::_Simple_types<class Product *> > > Product::tT

0 个答案:

没有答案