我刚刚学会了如何掩盖基类成员(使用new)但是我错过了为什么我想要这样做的观点.屏蔽是否为我们提供了一定程度的保护,就像使用封装一样?请指教.
我一定是在失去理智:-(.我不确定,但如果输入2,我就会得到肯定而且没有显示...
int main(void)
{
    int input;
    char yes[3] = "yes";
    char no[2] = "no";
    printf("Are you ok? Type in 1 for yes or 2 for no.\n");
    scanf("%d", &input);
    if (input == 1)
       printf("%s, I am\n.", yes);
    else
       printf("%s, I am not\n.", no);
    getchar();
    getchar();
}
Run Code Online (Sandbox Code Playgroud)