我使用 Visual Studio 2019 社区版编写此代码只是为了练习,但在代码的最后一行我不断收到“预期的 '}'”错误。当我单击运行时,它运行良好。这是为什么?
这是完整的代码。
#include <iostream>
#include <string>
using namespace std;
void funSayHi();
class People
{
public:
void callPeople(string x, int y, double z)
{
ResName = x;
ResAge = y;
ResHight = z;
cout << ResName << endl << ResAge << endl << ResHight << endl;
}
private:
string ResName = "No Name";
int ResAge = 0;
double ResHight = 0;
};
int main()
{
string name;
int age;
double hight;
funSayHi();
cout << "Enter name\n";
cin >> name;
cout << "Enter age\n";
cin >> age;
cout << "Enter hight\n";
cin >> hight;
People peopleObj;
peopleObj.callPeople(name, age, hight);
}
void funSayHi()
{
cout << "Hi\n";
} //VS 19 underlines this bracket and says "expected '}'"