class Student{
public:
Student(int test)
:key(705)
{
if(test == key)
{cout << "A student is being verified with a correct key: "<< test << endl;
allow=1;
}
else
{
cout << "Wrong key" ;
}
}
friend void printResult();
private:
const int key;
int allow;
};
void printResult()
{
if(allow==1)
{
cout<< " Maths: 75 \n Science:80 \n English: 75" << endl;
}
}
int main()
{
int testkey;
cout << "Enter key for Bob: ";
cin >> testkey;
Student …Run Code Online (Sandbox Code Playgroud) 为什么这没有任何错误?
int array[2];
array[5] = 21;
cout << array[5];
Run Code Online (Sandbox Code Playgroud)
打印出21就好了.但看看这个!我改变了5到46,它仍然有效.但是当我放47时,它没有打印任何东西.在任何地方都没有显示任 那是怎么回事!?!?