我的這個代碼為何在網(wǎng)站上通不過呢?
#include <iostream>
using namespace std;
class Coordinate
{
? ??
public:
Coordinate(int x, int y)
{
// 設置X,Y的坐標
m_iX = x;
? ? ? ? m_iY = y;
}
? ? // 實現(xiàn)常成員函數(shù)
void printInfo() const
{
? ?cout<<"("<<m_iX<<","<<m_iY<<")"<<endl;
}
public:
int m_iX;
int m_iY;
};
int main(void)
{
const Coordinate coor(3, 5);
// 創(chuàng)建常指針p
const Coordinate *p = &coor;
? ? // 創(chuàng)建常引用c
? ? const Coordinate &c = coor;
coor.printInfo();
p->printInfo();
c.printInfo(); ?
return 0;
}
2017-07-29
可能是卡了..復制然后重新打開練習題 黏貼上去提交看看..
2017-07-04
coor.printInfo();
p.printInfo();
c->printInfo(); ?//(*c).printInfo();?
這printInfo()部分的改成我這樣就能運行。
2016-04-16
你這個代碼是正確的,答案也是這個??赡苁蔷W(wǎng)站的問題。不用管它了
2016-04-16
這些代碼是正確的,我在VS中可以正常運行并且得到正解。在網(wǎng)頁上運行不通過可能是網(wǎng)頁自身編寫過程中設置出了問題。