C++ 未解析的外部符号,致命错误LNK1120
我试图创建一个程序,将物品的清单存储到动态数组中,同时跟踪物品ID、物品描述、数量和价格。唯一的问题是我得到一个未解决的外部符号错误C++ 未解析的外部符号,致命错误LNK1120,c++,fatal-error,C++,Fatal Error,我试图创建一个程序,将物品的清单存储到动态数组中,同时跟踪物品ID、物品描述、数量和价格。唯一的问题是我得到一个未解决的外部符号错误 "struct inventory item * * list", fatal error LNK1120. 知道问题是什么或如何解决吗 #include <iostream> #include <fstream> #include <string> #include <cctype> #include <
"struct inventory item * * list", fatal error LNK1120.
知道问题是什么或如何解决吗
#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
#include <vector>
using namespace std;
struct inventoryitem{
char itemid[7];
string itemDesc;
int quantity;
float price;
float retailprice;
};
inventoryitem *list[];
void add();
void edit();
void search();
void display();
void remove();
void textfile();
int main(){//main menu
while(true){
cout << "\nInventory Database Manager\n";
cout << "_____________________________\n";
cout << "What would you like to do?\n";
cout << "1) Add item to database\n";
cout << "2) Edit item in database\n";
cout << "3) Search the database for an item\n";
cout << "4) Delete an item in database\n";
cout << "5) Display all items\n";
//cout << "6) Exit program\n";
cout << "Input command (1-5)\n\n";
int input;
cin >> input;
switch(input){
case 1: add();
case 2: edit();
case 3: search();
case 4: remove();
case 5: display();
default : cout << "\nError, invalid input, try again";
}
}
}
int inc = 0;
void add(){
inventoryitem item;
cout << "\nEnter Item ID (3 letters followed by 4 digits)\n";
cin >> list[inc]->itemid;
for(int x = 0; x < 6; x++){//validates the item ID, checks if the first 3 digits are numbers first, then the next 4
if(x < 2){
if(isalpha(item.itemid[x])){
//do nothing
}
else{
cout << "Error, itemID is 3 letters followed by 4 digits";
break;
}
}
if(x > 2){
if(isdigit(item.itemid[x])){
//do nothing
}
else{
cout << "Error, itemID is 3 letters followed by 4 digits";
break;
}
}
}
cout << "Enter the item's description\n";
cin >> list[inc]->itemDesc;
cout << "Enter the quantity of item\n";
cin >> list[inc]->quantity;
cout << "Enter the price of the item\n";
cin >> list[inc]->price;
cout << "Enter the retail price of the item\n";
cin >> list[inc]->retailprice;
}
void edit(){}
void search(){}
void display(){}
void remove(){}
void textfile(){}
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
结构目录项{
char itemid[7];
字符串itemDesc;
整数;
浮动价格;
浮动零售价;
};
清单项目*列表[];
无效添加();
作废编辑();
无效搜索();
void display();
无效删除();
void textfile();
int main(){//主菜单
while(true){
零售价格;
}
void edit(){}
无效搜索(){}
void display(){}
void remove(){}
void textfile(){}
针对此行发出一个更有用的编译器错误:
inventoryitem *list[];
数组类型变量的定义需要显式大小或初始值设定项
<>在C++中,你最好使用一个可用的多个。
std::list<inventoryitem>
std::list
在我看来,你的问题在于你实际上没有在任何地方实例化你的列表……尽管我觉得奇怪,这是一个链接错误。