简体   繁体   English

错误代码= 0x80070002(MS Visual Studio)C ++

[英]Error code = 0x80070002 (MS Visual Studio) C++

Well, I wrote a simple code to check the possibility of creating objects using 'new' operator. 好吧,我编写了一个简单的代码来检查使用“ new”运算符创建对象的可能性。 When I was trying to compile the code, the MS Visual Studio threw the error like this: " Error: Unable to open file C:\\Users...\\test1\\Debug\\main.obj. Error code = 0x80070002.Error: Could not find 'C:\\Users...\\test1\\Debug\\main.obj'. test1.exe was built with /DEBUG:FASTLINK which requires object files for debugging. 当我尝试编译代码时,MS Visual Studio抛出如下错误:“错误:无法打开文件C:\\ Users ... \\ test1 \\ Debug \\ main.obj。错误代码= 0x80070002.Error:可以找不到'C:\\ Users ... \\ test1 \\ Debug \\ main.obj'。test1.exe是使用/ DEBUG:FASTLINK构建的,它需要目标文件进行调试。

What is going on? 到底是怎么回事? Please help. 请帮忙。

Code: 码:

#include <iostream>

class czlowiek {
int wiek;
char plec;
czlowiek();
czlowiek(int Wiek, int Plec);
};

czlowiek::czlowiek(int Wiek, int Plec) {
    wiek = Wiek;
    plec = Plec;
}

int main()
{
czlowiek *first;
first = new czlowiek();
delete first;
std::cin.get();
return 0;
}

The code you posted will not link: 您发布的代码将不会链接:

  • The constructor czlowiek() doesn't have an implementation. 构造函数czlowiek()没有实现。
  • Both constructors are private (in classes members and methods are private by default). 这两个构造函数都是私有的(在类中,成员和方法默认情况下都是私有的)。

As warning, you are assigning a int to a char (plec). 作为警告,您正在将一个int分配给char(plec)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM