c++小程序 出现error LNK2001 求救大神!!!
#include<iostream>#include<fstream>#include<string>usingnamespacestd;classComFile{cha...
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
class ComFile
{
char name1[20];
char name2[20];
public:
ComFile();
void Input();
void Getline();
};
void ComFile::Input()
{
cout<<"请输入第一个文件路径文件名:"<<endl;
cin>>name1;
cout<<"请输入第二个文件路径文件名:"<<endl;
cin>>name2;
}
void ComFile::Getline()
{
ifstream readfile1("name1",ios::in);//打开第一个文件
if(!readfile1)
{
cout<<"不能打开文件1"<<endl;
exit(1);
}
ifstream readfile2("name2",ios::in);//打开第二个文件
if(!readfile2)
{
cout<<"不能打开文件2"<<endl;
exit(1);
}
char str1[100];
char str2[100];
char n='Y';
while((!readfile1.eof())&&(!readfile2.eof())&&(n=='Y'))
{
readfile1.getline(str1,100);
readfile2.getline(str2,100);
if(str1!=str2)
{
cout<<"文件一中该行的内容:"<<str1<<endl;
cout<<"文件二中该行的内容:"<<str2<<endl;
}
cout<<"您是否要继续判断?请输入Y or N"<<endl;
cin>>n;
}
}
int main()
{
ComFile com;
com.Input();
com.Getline();
return 0;
}
Linking...
2-7.obj : error LNK2001: unresolved external symbol "public: __thiscall ComFile::ComFile(void)" (??0ComFile@@QAE@XZ)
Debug/2-7.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
2-7.exe - 2 error(s), 0 warning(s) 展开
#include<fstream>
#include<string>
using namespace std;
class ComFile
{
char name1[20];
char name2[20];
public:
ComFile();
void Input();
void Getline();
};
void ComFile::Input()
{
cout<<"请输入第一个文件路径文件名:"<<endl;
cin>>name1;
cout<<"请输入第二个文件路径文件名:"<<endl;
cin>>name2;
}
void ComFile::Getline()
{
ifstream readfile1("name1",ios::in);//打开第一个文件
if(!readfile1)
{
cout<<"不能打开文件1"<<endl;
exit(1);
}
ifstream readfile2("name2",ios::in);//打开第二个文件
if(!readfile2)
{
cout<<"不能打开文件2"<<endl;
exit(1);
}
char str1[100];
char str2[100];
char n='Y';
while((!readfile1.eof())&&(!readfile2.eof())&&(n=='Y'))
{
readfile1.getline(str1,100);
readfile2.getline(str2,100);
if(str1!=str2)
{
cout<<"文件一中该行的内容:"<<str1<<endl;
cout<<"文件二中该行的内容:"<<str2<<endl;
}
cout<<"您是否要继续判断?请输入Y or N"<<endl;
cin>>n;
}
}
int main()
{
ComFile com;
com.Input();
com.Getline();
return 0;
}
Linking...
2-7.obj : error LNK2001: unresolved external symbol "public: __thiscall ComFile::ComFile(void)" (??0ComFile@@QAE@XZ)
Debug/2-7.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
2-7.exe - 2 error(s), 0 warning(s) 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询