weixin_45658815 2021-04-08 10:43 采纳率: 40%
浏览 31

两段代码仅注释处不一样,为什么第二个代码会出错呢,求问大佬,谢谢! 一` #include<ios

两段代码仅注释处不一样,为什么第二个代码会出错呢,求问大佬,谢谢! 一` #include<iostream> using namespace std; class Sample { int x, y; public: Sample() { x = y = 0; } Sample(int a, int b) { x = a, y = b; } void disp() { cout << "x=" << x << ",y=" << y << endl; } }; void main() { Sample s(2, 3), *p = &s;//此处 p->disp(); } 二、 #include<iostream> using namespace std; class Sample { int x, y; public: Sample() { x = y = 0; } Sample(int a, int b) { x = a, y = b; } void disp() { cout << "x=" << x << ",y=" << y << endl; } }; void main() { Sample s(2, 3); *p = &s;//此处有错误 p->disp(); }
  • 写回答

2条回答 默认 最新

  • 8号店长 2021-04-08 11:02
    关注

    代码用代码段写出来

    一般来说如果完全一样,可能是中文空格问题,标点符号问题等

    评论

报告相同问题?