我一直在寻找这个问题的答案大约4个小时而且很痛苦,到目前为止,我已经遇到了多个关于如何摆脱实际错误的修复,我已经阅读了以前的近两整页海报LNK2019& LNK1120错误,我仍然不明白修复程序到目前为止如何工作,我没有包括任何外部库。我试图找到我正在寻找的东西,但说实话我不明白我在寻找什么,因为我没有实现外部API或任何类型的东西,好吧,我不相信,这是我的朋友代码,所以我不知道他实现了什么,请帮助,也是,这里也是源代码。
错误LNK2019未解析的外部符号“void __cdecl displaySpace(int,class> std :: basic_string,class std :: allocator>,bool,char)“(?displaySpace @@ YAXHV?$ basic_string @ DU? $ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ _ ND @ Z)在函数_main中引用
(它也说它在第1行)
LNK1120,1个未解决的外部因素(它也说它在第1行)
#include <string>
#include <iostream>
#include <array>
using namespace std;
int main()
{
string userString;
const int maxWordLength = 32;
char userWord[maxWordLength];
char remainingLetters[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
int health = 0;
int wordLength = 0;
int letterFind = 0;
int index = 0;
bool gameOver = false;
bool inputValid = false;
bool inputValid2 = false;
char guessChar = ' ';
void displaySpace(int wordLength, string userWord, bool correctGuess, char guessChar);
while (!inputValid)
{
//ask for pharse/word
cout << "Player 1, pick a word or pharse less than (no caps) " << maxWordLength << " characters: " << endl;
getline(cin, userString);
//cout << userString << endl;
wordLength = userString.length();
// << wordLength << endl;
if (wordLength <= maxWordLength)
{
//skips down so player 2 does not cheat
for (int i = 0; i < 100; i++)
{
cout << " " << endl;
}
for (int i = 0; i < wordLength; i++)
{
userWord[i] = userString[i];
}
displaySpace(wordLength, userWord, false, guessChar);
inputValid = true;
}
else
{
continue;
}
while (!gameOver)
{
cout << " " << endl;
cout << "Player 2, guess a letter in the phrase/word: " << endl;
cin >> guessChar;
while (!inputValid2)
{
if (!isalpha(guessChar))
{
continue;
}
else
{
cin >> guessChar;
for (int i = 0; i < wordLength; i++)
{
if (userWord[i] == guessChar)
{
for (int k = 0; k < 26; k++)
{
if (remainingLetters[k] == guessChar)
{
for (index = k; index < 26; index++)
{
int temp = remainingLetters[index];
remainingLetters[index] = remainingLetters[index + 1];
remainingLetters[index + 1] = temp;
}
for (int index = 0; index < k; index++)
{
cout << remainingLetters[index] << " ";
}
for (int i = 0; i < 26; i++)
{
cout << remainingLetters[i] << endl;
}
}
else
{
continue;
}
}
}
else
{
}
}
inputValid = true;
}
}
}
}
return 0;
}
void displaySpace(int wordLength, string userWord, bool correctGuess, char
guessChar, char remainingLetters[26])
{
string displayspace[32]= {" "," ", " ", " ", " ", " ", " ", " ", " ", " ", "
", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "
", " ", " ", " ", " ", " ", " ", };
string space = " ";
string dash = " _ ";
string guessString(1, guessChar);
cout << guessString << endl;
for (int i = 0; i < 32; i++) {
displayspace[i] = " ";
}
for (int i = 0; i < wordLength; i++)
{
for (int k = 0; i < 26; i++) {
if (remainingLetters[k] == userWord[i])
{
displayspace[i] = dash;
cout << dash;
}
}
if (correctGuess == true)
{
displayspace[i] = guessString;
cout << guessString;
}
else
{
displayspace[i] = space;
cout << space;
}
}
for (int i = 0; i < wordLength; i++)
{
cout << displayspace[i];
}
}
答案 0 :(得分:1)
您在函数原型(和调用站点)之间存在不匹配:
@Bind(R.id.webView)
WebView webView;
private String iteamRichText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
ButterKnife.bind(this);
final Intent mIntent = getIntent();
iteamRichText = mIntent.getExtras().getString(getResources().getString(R.string.putkey_iteam_richText));
webView.setWebViewClient(new MyBrowser());
// webView.getSettings().setLoadsImagesAutomatically(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setLoadWithOverviewMode(true);
// webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
webView.getSettings().setSupportMultipleWindows(false);
webView.getSettings().setUseWideViewPort(false);
webView.setScrollbarFadingEnabled(true);
webView.setFocusableInTouchMode(false);
webView.setFocusable(false);
webView.loadData(iteamRichText, "text/html", "UTF-8");
}
private class MyBrowser extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//view.loadData(iteamRichText, "text/html", "UTF-8");
view.loadUrl(url);
Log.e("process", "" + url);
if(url.startsWith("http") && (url.contains(".jpg") || url.contains(".png") || url.contains(".jpeg") || url.contains(".gif")))
{
Intent mIntent = new Intent(WebViewActivity.this, FullScreenImgActivity.class);
mIntent.putExtra(getResources().getString(R.string.putkey_webViewfullImagePath), url);
startActivity(mIntent);
}
return true;
}
}
和实际的功能定义:
void displaySpace(int wordLength, string userWord, bool correctGuess, char guessChar);
这就是编译器无法找到匹配函数的原因。