using namespace std;
class Student{
public:
Student(int test)
{
if(test == key)
{cout << "A student is being verified with a correct key: "<< test << endl;}
}
private:
int key= 705;
};
int main()
{
int testkey;
cout << "Enter key for Bob: ";
cin >> testkey;
Student bob(testkey);
}
所以我尝试运行它,但它说 C++ 无法为键分配值“错误使键成为静态”。我不知道这是什么意思:(