哪里错了哟
Undefined symbols for architecture x86_64:
"Coordinate::Coordinate()", referenced from:
_main in demo-ce037c.o
"Coordinate::~Coordinate()", referenced from:
_main in demo-ce037c.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Undefined symbols for architecture x86_64:
"Coordinate::Coordinate()", referenced from:
_main in demo-ce037c.o
"Coordinate::~Coordinate()", referenced from:
_main in demo-ce037c.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
2018-04-25
#include <iostream>
using namespace std;
class Coordinate
{
public:
Coordinate(int x, int y)
{
// 设置X,Y的坐标
m_iX=x;
m_iY=y;
}
// 实现常成员函数
void printInfo() const
{
cout<<"("<<m_iX<<","<<m_iY<<")"<<endl;
}
public:
int m_iX;
int m_iY;
};
using namespace std;
class Coordinate
{
public:
Coordinate(int x, int y)
{
// 设置X,Y的坐标
m_iX=x;
m_iY=y;
}
// 实现常成员函数
void printInfo() const
{
cout<<"("<<m_iX<<","<<m_iY<<")"<<endl;
}
public:
int m_iX;
int m_iY;
};
寒假自己看了前面将近300页的C++primer5,然后又看完了老师的C++这些基础视频视频.现在开学了,有些东西忘了,再来回顾下
2018-04-19
#include <iostream>
using namespace std;
class Coordinate
{
public:
Coordinate()
{
cout<<"Coordinate()"<<endl;
}
// 打印坐标的函数
void printInfo()
{
cout<<m_iX<<","<<m_iY<<endl;
}
public:
int m_iX;
int m_iY;
}
using namespace std;
class Coordinate
{
public:
Coordinate()
{
cout<<"Coordinate()"<<endl;
}
// 打印坐标的函数
void printInfo()
{
cout<<m_iX<<","<<m_iY<<endl;
}
public:
int m_iX;
int m_iY;
}
int main(void)
{
Coordinate *coorArr = new Coordinate();
coorArr[0].m_iX = 1;
coorArr[0].m_iY = 2;
coorArr[1].m_iX = 3;
coorArr[1].m_iY = 4;
//遍历数组,打印对象信息
for(int i = 0; i < 2; i++)
{
coorArr[i].printInfo();
}
delete []coorArr;
coorArr = NULL;
return 0;
}
{
Coordinate *coorArr = new Coordinate();
coorArr[0].m_iX = 1;
coorArr[0].m_iY = 2;
coorArr[1].m_iX = 3;
coorArr[1].m_iY = 4;
//遍历数组,打印对象信息
for(int i = 0; i < 2; i++)
{
coorArr[i].printInfo();
}
delete []coorArr;
coorArr = NULL;
return 0;
}