Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/160.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 无法对商店进行盘点_C++_Vector - Fatal编程技术网

C++ 无法对商店进行盘点

C++ 无法对商店进行盘点,c++,vector,C++,Vector,Store.cpp: table[plu_code] = new Product(plu_code, name, sold_by_weight, price, inv);//This will call look up table operator '[]' num_products++; // counting number of items in inventory 可查找。h: private: T *aptr[MAXRANGE]; int rangeStart[MAXRANGE]; i

Store.cpp:

table[plu_code] = new Product(plu_code, name, sold_by_weight, price, inv);//This will call look up table operator '[]'
num_products++; // counting number of items in inventory
可查找。h:

private:
T *aptr[MAXRANGE];
int rangeStart[MAXRANGE];
int rangeEnd[MAXRANGE];
int numRanges;
T defaultValue; //needed to return when [] operator does not find valid product


T &LookupTable<T>::operator[](int value)
{ 
// find the range
if (value>0 && value<9999) //inorganic tems
    return aptr[0][value-rangeStart[0]];
else if (value>90000 && value<99999)//organic items
    return aptr[1][value - rangeStart[1]];
else
    return defaultValue;
}

问题是当指针返回时,它无法为产品对象分配地址。

无法理解您的问题我正在尝试返回指针,然后分配产品对象。但调试后,显示指针/表[plu_code]中没有对象字段