- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
我的问题查了没用所以特地来问一下。当我运行我的代码并查看一个零件文件时,它是零件类,有多少零件以及它的成本是多少,它应该告诉我它在文件中的位置以及它是否不是,将其添加到文件中。在教授的帮助下,我纠正了很多错误,但我不断收到 Unresolved external 错误。确切地说是五个。我真的不明白这是什么意思。这是代码和错误:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <fstream>
#include <string>
#include <algorithm>
using namespace std;
// Sorts vectors (Calls swapper)
void sort(vector<string>& part_number, vector<char>& part_class, vector<int>&ohb, vector<double>& cost);
// Fills vectors
bool get_data (vector <string>& part_number, vector <char>& part_class, vector<int>& part_ohb, vector <double>& part_cost);
// Does a binary search
int bin_search(string key, const vector<string>& part_number);
// Asks user for a part number to search for
void get_target();
// Gets remaining info to add a part number
void get_more_data(char& class_in,int& part_ohb_in,double& part_cost_in);
// Inserts part number data into vectors into the proper location (code for this given below)
void insert_data (vector <string>& part_number, vector <char>& part_class, vector <int>& part_ohb, vector <double>& part_cost, string part_in, char class_in, int part_ohb_in, double part_cost_in);
// Displays info on part number
void display (const vector <string>& part_number, const vector <char>& part_class, const vector <int>& part_ohb, const vector <double>& part_cost, int finder);
// Prints search stats
void print_stats(int searches, int good, int bad);
// Writes out file
void put_data (const vector <string>& part_number, const vector <char>& part_class, const vector <int>& part_ohb, const vector <double>& part_cost);
// Templated swap function. Swaps two items in a vector of any type
template <class CType> void swapper (CType& a, CType & b);
int main() {
vector <string> part_number;
vector <char> part_class;
vector <int> part_ohb;
vector <double> part_cost;
string key, part_in;
int part_ohb_in, searches, good, bad, finder;
char class_in, response;
double part_cost_in;
do {
get_target();
searches++;
get_data (part_number, part_class, part_ohb, part_cost);
sort(part_number, part_class, part_ohb, part_cost);
finder = bin_search(key, part_number);
if (finder == -1) {
cout << part_in << "not found!\n";
get_more_data(class_in, part_ohb_in, part_cost_in);
cout << "Adding part into library...\n";
bad++;
insert_data (part_number, part_class, part_ohb, part_cost, part_in, class_in, part_ohb_in, part_cost_in);
sort(part_number, part_class, part_ohb, part_cost);
}
else {
display (part_number, part_class, part_ohb, part_cost, finder);
good++;
}
cout << "Would you like to search again?" << endl;
} while (toupper(response) != 'Y');
print_stats(searches, good, bad);
put_data (part_number, part_class, part_ohb, part_cost);
return 0;
}
void sort(vector<string>& part_number, vector<char>& part_class, vector<int>& part_ohb, vector<double>& part_cost) {
int i, j, increment;
string temp_pn;
char temp_pc;
int temp_ohb;
double temp_cost;
increment = 3;
while (increment > 0) {
for (i=0; i < part_number.size(); i++) {
j = i;
swapper(temp_pn, part_number[i]);
swapper(temp_pc, part_class[i]);
swapper(temp_ohb, part_ohb[i]);
swapper(temp_cost, part_cost[i]);
while ((j >= increment) && (part_number[j-increment] > temp_pn)) {
swapper(part_number[j], part_number[j - increment]);
swapper(part_class[j], part_class[j - increment]);
swapper(part_ohb[j], part_ohb[j - increment]);
swapper(part_cost[j], part_cost[j - increment]);
j = j - increment;
}
swapper( part_number[j], temp_pn);
swapper( part_class[j], temp_pc);
swapper( part_ohb[j], temp_ohb);
swapper( part_cost[j], temp_cost);
}
if (increment/2 != 0) {
increment = increment/2;
}
else if (increment == 1) {
increment = 0;
}
else {
increment = 1;
}
}
}
bool get_data (vector <string>& part_number, vector <char>& part_class, vector <int>& part_ohb, vector <double>& part_cost) {
bool OK = true;
string partIn;
int ohbIn;
char classIn;
double costIn;
ifstream myFile;
myFile.open("parts.txt");
if (myFile.fail()) {
OK = false;
}
else {
while(myFile >> partIn >> classIn >> ohbIn >> costIn) {
part_number.push_back(partIn);
part_class.push_back(classIn);
part_ohb.push_back(ohbIn);
part_cost.push_back(costIn);
myFile.close();
}
}
return OK;
}
int bin_search(string key, const vector<string>& part_number) {
bool found = false;
int first, mid, last, return_val;
first = 0;
last = part_number.size()-1;
while ((first <= last) && (!found)) {
mid = (first + last) / 2;
if (key == part_number[mid]) {
found = true;
}
else {
if (key < part_number[mid]) {
last = mid - 1;
}
else {
first = mid + 1;
}
}
}
if (found) {
return_val = mid;
}
else {
return_val = -1;
}
return return_val;
}
void get_target(string& key) {
cout << "What part number should I search for?" << endl;
cin >> key;
}
void get_more_data(char& class_in, int& part_ohb_in, double& part_cost_in) {
cout << "Please add in the part class, how many of them there are, and the cost per part: ";
cin >> class_in >> part_ohb_in >> part_cost_in;
}
void insert_data (vector <string>& part_number, vector <char>& part_class, vector <int>& part_ohb, vector <double>& part_cost, string part_in, char class_in, int part_ohb_in, double part_cost_in) {
part_number.push_back(part_in);
part_class.push_back(class_in);
part_ohb.push_back(part_ohb_in);
part_cost.push_back(part_cost_in);
}
void display (const vector <string>& part_number, const vector <char>& part_class, const vector <int>& part_ohb, const vector <double>& part_cost, int finder) {
int total = part_ohb[finder] * part_cost[finder];
cout << "There are " << part_ohb[finder] << " of Part Number " << part_number[finder] << " in inventory. It is a class " << part_class[finder] << " part. The cost is " << part_cost[finder] << ". The value of that inventory is " << total << ".\n";
}
void print_stats(int searches, int good, int bad) {
cout << "You made " << searches << " searches with " << good << " successful searches and " << bad << " bad searches.\n";
}
void put_data (const vector <string>& part_number, const vector <char>& part_class, const vector <int>& part_ohb, const vector <double>& part_cost) {
// for loop for displaying
ofstream myfile;
myfile.open ("parts.txt");
for (int i = 0; i < part_number.size(); i++) {
myfile << part_number[i] << " " << part_class[i] << " " << part_ohb[i] << " " << part_cost[i] << endl;
}
myfile.close();
}
错误:
1>Project3Source.obj : error LNK2019: unresolved external symbol "void __cdecl get_target(void)" (?get_target@@YAXXZ) referenced in function _main
1>Project3Source.obj : error LNK2019: unresolved external symbol "void __cdecl swapper<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (??$swapper@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@YAXAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) referenced in function "void __cdecl sort(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &,class std::vector<char,class std::allocator<char> > &,class std::vector<int,class std::allocator<int> > &,class std::vector<double,class std::allocator<double> > &)" (?sort@@YAXAAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AAV?$vector@DV?$allocator@D@std@@@2@AAV?$vector@HV?$allocator@H@std@@@2@AAV?$vector@NV?$allocator@N@std@@@2@@Z)
1>Project3Source.obj : error LNK2019: unresolved external symbol "void __cdecl swapper<char>(char &,char &)" (??$swapper@D@@YAXAAD0@Z) referenced in function "void __cdecl sort(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &,class std::vector<char,class std::allocator<char> > &,class std::vector<int,class std::allocator<int> > &,class std::vector<double,class std::allocator<double> > &)" (?sort@@YAXAAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AAV?$vector@DV?$allocator@D@std@@@2@AAV?$vector@HV?$allocator@H@std@@@2@AAV?$vector@NV?$allocator@N@std@@@2@@Z)
1>Project3Source.obj : error LNK2019: unresolved external symbol "void __cdecl swapper<int>(int &,int &)" (??$swapper@H@@YAXAAH0@Z) referenced in function "void __cdecl sort(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &,class std::vector<char,class std::allocator<char> > &,class std::vector<int,class std::allocator<int> > &,class std::vector<double,class std::allocator<double> > &)" (?sort@@YAXAAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AAV?$vector@DV?$allocator@D@std@@@2@AAV?$vector@HV?$allocator@H@std@@@2@AAV?$vector@NV?$allocator@N@std@@@2@@Z)
1>Project3Source.obj : error LNK2019: unresolved external symbol "void __cdecl swapper<double>(double &,double &)" (??$swapper@N@@YAXAAN0@Z) referenced in function "void __cdecl sort(class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > &,class std::vector<char,class std::allocator<char> > &,class std::vector<int,class std::allocator<int> > &,class std::vector<double,class std::allocator<double> > &)" (?sort@@YAXAAV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@AAV?$vector@DV?$allocator@D@std@@@2@AAV?$vector@HV?$allocator@H@std@@@2@AAV?$vector@NV?$allocator@N@std@@@2@@Z)
1>C:\Users\Austin Julio\Desktop\CMPSC 121\Projects\Project 3\Debug\Project 3.exe : fatal error LNK1120: 5 unresolved externals
节点版本:v6.11.0 错误信息: Unable to resolve path to module './coins.json'. (import/no-unresolved) 我还附上错误的屏幕
我的 flutter 应用程序运行良好,直到我停止成功构建的日子 android/app/src/main/kotlin/com/apps/myapp/MainActivity.kt 文件 packa
我在使用 kotlin 版本 1.3.41 的 kotlin 项目中遇到问题 Unresolved reference :我无法找出为什么会出现该问题?。我也降级了 kotlin 版本但没有效果。 当
在编译我的代码时,我收到此错误。 1>MSVCRTD.lib(crtexe.obj):错误 LNK2019:函数 ___tmainCRTStartup 中引用了未解析的外部符号 _main1>C:\U
我一直遇到这两个错误,但我似乎找不到有效的解决方案。 LNK1120: 1 unresolved externals Error 1 error LNK2019: unresolved externa
我想使用 SQLite,但出现 Unresolved -* 错误。以下是我所做工作的总结: 这是三个目录: 源文件 -->include -->src -->sqlite3 我已将以上三个目录全部添加
我在尝试构建时收到以下错误: 1> MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 r
我在构建程序时不断收到“未解析的外部符号”错误。但是,该程序编译正常。我正在使用 GLFW 和 GLAD 库。 #include #include #include void framebuff
我是谷歌测试框架的新手。这是我的第一个谷歌测试测试项目。我做了像这个网站http://www.bogotobogo.com/cplusplus/google_unit_test_gtest.php这样
当我尝试编译我的代码时,我遇到了两个错误。我已经定义了 win32 控制台应用程序。我什至还没有开始编码。我的配置如下 - 链接器 - 子系统 - 控制台;链接器 - 高级 - 入口点 - 空白。
我尝试构建我的应用程序,但失败了,仅显示一条消息: Failed to resolve: play-services-basement 我的应用程序昨天成功构建。自昨天成功构建以来,没有代码更改。我的
任务是找到所有可表示为两个自然数的开方之和的二值数。我试试这个: func = [sqrt (x) + sqrt (y) | x a -> a mod :: Integral a => a -> a
Kotlin: Unresolved reference: totalFee 我只是在做这个小虚拟程序来练习,但它说totalFee尝试将值打印到屏幕时未解决。我已经看了一段时间了,不知道为什么。da
我正在编写一个小程序来判断字符串数组向前和向后读取是否相同。现在我的程序应该返回 false。我遇到了一些困难,因为当我扫描数组时,我希望第二个 for 循环扫描第一个 for 循环所在的相同索引,但
请问有人可以针对我的问题发布错误更正并经过测试的代码吗?程序确实 - 22.php 具有以下形式。当用户输入并单击“提交”按钮时,结果应从 23.php 中获取并显示在 22.php 上的 div 中
当我编译它时给出错误信息: usimage.cpp Generating Code... Linking... Creating library .\Output/gci2.lib and ob
我有以下项目文件: //connections.cpp #include "stdafx.h" #include "LibraryHeaders.h" #include "FileManager.h"
我正在写一个游戏,但我遇到了一个问题,导致“C++ Unresolved external 问题” ** 我的类(class):** Terrain.h Class Terrain {}; 物理对象.
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
我正在使用 Visual Studio 2012 完成编程原则和实践中的练习。尝试编译下面的源代码时,我遇到了链接器错误: unresolved symbol int foo. 我不明白为什么符号没有
我是一名优秀的程序员,十分优秀!