Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/144.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++ 错误LNK2019和错误LNK1120 //OP8.6.1(1) #包括“stdafx.h” #包括 #包括 #包括 #包括 #包括“krypto.h” #包括“krypto.h” 使用名称空间std; int _tmain(int argc,_TCHAR*argv[] { 氪数据; cout数据; 不能改变这一点: //opgave 8.6.1(1) #include "stdafx.h" #include <iostream> #include <fstream> #include <vector> #include <string> #include "krypto.h" #include "krypto.h" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { krypto data; cout << "skriv her:"; data.hentdata(); system("pause"); return 0; } //Krypto.h #pragma once class krypto { public: krypto(); void hentdata(); private: char data; }; //krypto.cpp #include "stdafx.h" #include <iostream> #include <fstream> #include <vector> #include <string> #include "krypto.h" using namespace std; krypto::krypto() { } void hentinput(){ char data; cout << "Skriv dit input: "; cin >> data; cout << data; }_C++ - Fatal编程技术网

C++ 错误LNK2019和错误LNK1120 //OP8.6.1(1) #包括“stdafx.h” #包括 #包括 #包括 #包括 #包括“krypto.h” #包括“krypto.h” 使用名称空间std; int _tmain(int argc,_TCHAR*argv[] { 氪数据; cout数据; 不能改变这一点: //opgave 8.6.1(1) #include "stdafx.h" #include <iostream> #include <fstream> #include <vector> #include <string> #include "krypto.h" #include "krypto.h" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { krypto data; cout << "skriv her:"; data.hentdata(); system("pause"); return 0; } //Krypto.h #pragma once class krypto { public: krypto(); void hentdata(); private: char data; }; //krypto.cpp #include "stdafx.h" #include <iostream> #include <fstream> #include <vector> #include <string> #include "krypto.h" using namespace std; krypto::krypto() { } void hentinput(){ char data; cout << "Skriv dit input: "; cin >> data; cout << data; }

C++ 错误LNK2019和错误LNK1120 //OP8.6.1(1) #包括“stdafx.h” #包括 #包括 #包括 #包括 #包括“krypto.h” #包括“krypto.h” 使用名称空间std; int _tmain(int argc,_TCHAR*argv[] { 氪数据; cout数据; 不能改变这一点: //opgave 8.6.1(1) #include "stdafx.h" #include <iostream> #include <fstream> #include <vector> #include <string> #include "krypto.h" #include "krypto.h" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { krypto data; cout << "skriv her:"; data.hentdata(); system("pause"); return 0; } //Krypto.h #pragma once class krypto { public: krypto(); void hentdata(); private: char data; }; //krypto.cpp #include "stdafx.h" #include <iostream> #include <fstream> #include <vector> #include <string> #include "krypto.h" using namespace std; krypto::krypto() { } void hentinput(){ char data; cout << "Skriv dit input: "; cin >> data; cout << data; },c++,C++,为此: void hentinput() { char data; ... } void hentdata();的实现在哪里?除了缺少的函数没有命名为hentinput。更可能的情况是将其重命名为void krypto::hentdata()会起作用,虽然很难说这是不是正确的解决方案,但它会修复链接错误。@RetiredInja:是的,我同意。解决手头的问题也不费吹灰之力。我修复了答案,但会考虑删除它…@SteffenKjærThomsen:不客气。试着用一种轻松的方式编写代码

为此:

void hentinput()
{
    char data;
    ...
}

void hentdata();
的实现在哪里?除了缺少的函数没有命名为
hentinput
。更可能的情况是将其重命名为
void krypto::hentdata()
会起作用,虽然很难说这是不是正确的解决方案,但它会修复链接错误。@RetiredInja:是的,我同意。解决手头的问题也不费吹灰之力。我修复了答案,但会考虑删除它…@SteffenKjærThomsen:不客气。试着用一种轻松的方式编写代码如果你更有条理,将来会对你有所帮助。
void krypto::hentdata()
{
    ...
}