我得到了这个错误:隐式声明 我只是一个C++初学者,所以我只想做一个简单的程序。 但我做这件事遇到了很多麻烦。 请告诉我如何修复这个错误,因为我对构造函数不太了解 #include <iostream> #include<windows.h> #include<fstream> using namespace std; int main() { MessageBox(NULL,"YOU HAVE BEEN PROMOTED TO TEST THIS CONSOLE APP FOR FREE!!","PROMOTION!!",NULL); cout << "Hello world!............ first do you want this program to changeyour files to save progress??" << endl; int save; cout << "press 1 to allow press 2 to deny!!"<<endl; cin >> save; if(save == 1){ ofstream myfile; myfile.open ("data.txt"); } if(save == 2 ); cout<<"set up done!!!"<<endl; return 0; }

我得到了这个错误:隐式声明 我只是一个C++初学者,所以我只想做一个简单的程序。 但我做这件事遇到了很多麻烦。 请告诉我如何修复这个错误,因为我对构造函数不太了解 #include <iostream> #include<windows.h> #include<fstream> using namespace std; int main() { MessageBox(NULL,"YOU HAVE BEEN PROMOTED TO TEST THIS CONSOLE APP FOR FREE!!","PROMOTION!!",NULL); cout << "Hello world!............ first do you want this program to changeyour files to save progress??" << endl; int save; cout << "press 1 to allow press 2 to deny!!"<<endl; cin >> save; if(save == 1){ ofstream myfile; myfile.open ("data.txt"); } if(save == 2 ); cout<<"set up done!!!"<<endl; return 0; },c++,C++,最后是我的球员课 #ifndef PLAYER_H #define PLAYER_H class Player { int Player_helth(){ Player_helth0 = 200; return player_helth0; } void patt(){ public: int power_punch = - 20; } }; #endif // PLAYER_H 我不知道为什么会出现这个错误 ` 看起来错误在于,当您试图声明变量P

最后是我的球员课

#ifndef PLAYER_H
#define PLAYER_H


class Player
{

 int Player_helth(){
 Player_helth0 = 200;
 return player_helth0;

 }
 void patt(){
public:

    int power_punch = - 20;

 }





};

#endif // PLAYER_H
我不知道为什么会出现这个错误

`

看起来错误在于,当您试图声明变量Player_helth0时,您没有指示类型。应该是:

int Player_helth0 = 200;

我也看到了另一个(不相关的)问题。在Boss\u helth中,您的返回值应该是变量Boss\u helth0,但您将返回对函数的调用。

ummmm。。。什么错误?@Aaron Hill,你问题标题中的“隐式声明”给了我一个提示,但你真的应该将错误添加到问题主体中,并包含整个错误消息。这样就更容易理解这个问题了。。。它的内容是:隐式声明的“Boss::Boss()”的定义。
int Player_helth0 = 200;