0

可能重复:
什么是未定义的引用/未解决的外部符号错误,我该如何解决?

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

//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>book.obj:错误 LNK2001:无法解析的外部符号“ public: static class std::vector<class Product *,class std::allocator<class Product *> > Product::plist

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

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

1>ProductCatalog.obj:错误LNK2019:函数“ ”public: __thiscall Product::Product(void)中引用了无法解析的外部符号“”(??0Product@@QAE@XZ)public: __thiscall ProductCatalog::ProductCatalog(void)

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

4

0 回答 0