Array.h:
#pragma once
#include"iostream"
#include"stdlib.h"
using namespace std;
class Array {
public:
Array() {};
~Array() {};
Array(const Array & arr);
void set_Arrary(int count);
int get_Arrary();
private:
int m_iCount;
};
#pragma once
#include"iostream"
#include"stdlib.h"
using namespace std;
class Array {
public:
Array() {};
~Array() {};
Array(const Array & arr);
void set_Arrary(int count);
int get_Arrary();
private:
int m_iCount;
};
2019-01-29
Array.cpp:
#include"array.h"
void Array::set_Arrary(int count) {
m_iCount = count;
}
int Array::get_Arrary() {
return m_iCount;
}
Array::Array(const Array & arr) {
m_iCount = arr.m_iCount;
}
#include"array.h"
void Array::set_Arrary(int count) {
m_iCount = count;
}
int Array::get_Arrary() {
return m_iCount;
}
Array::Array(const Array & arr) {
m_iCount = arr.m_iCount;
}
2019-01-29
源:
#include"array.h"
int main() {
Array arr1;
arr1.set_Arrary(6);
Array arr2(arr1);
cout << arr2.get_Arrary();//实现部分
return 0;
}
#include"array.h"
int main() {
Array arr1;
arr1.set_Arrary(6);
Array arr2(arr1);
cout << arr2.get_Arrary();//实现部分
return 0;
}
2019-01-29
B:
int main(void) {
Coordinate coorArr[2];
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();
}
return 0;
}
int main(void) {
Coordinate coorArr[2];
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();
}
return 0;
}
应付测试的版本:
A:
#include <iostream>
using namespace std;
class Coordinate {
public:
Coordinate() {};
void printInfo();
public:
int m_iX;
int m_iY;
};
void Coordinate::printInfo() {
cout << "(" << m_iX << "," << m_iY << ")" << endl;
}
A:
#include <iostream>
using namespace std;
class Coordinate {
public:
Coordinate() {};
void printInfo();
public:
int m_iX;
int m_iY;
};
void Coordinate::printInfo() {
cout << "(" << m_iX << "," << m_iY << ")" << endl;
}
B:
line::line(int x1, int y1, int x2, int y2) :m_coorA(x1, y1), m_coorB(x2, y2) {}
void main() {
line *p = new line(1, 2, 3, 4);
delete[]p;
}
line::line(int x1, int y1, int x2, int y2) :m_coorA(x1, y1), m_coorB(x2, y2) {}
void main() {
line *p = new line(1, 2, 3, 4);
delete[]p;
}
2019-01-27
A:
#include"iostream"
using namespace std;
class Coordinate {
public:
Coordinate(int x, int y) {};
private:
int m_ix;
int m_iy;
};
class line {
public:
line(int x1, int y1, int x2, int y2);
private:
Coordinate m_coorA;
Coordinate m_coorB;
};
#include"iostream"
using namespace std;
class Coordinate {
public:
Coordinate(int x, int y) {};
private:
int m_ix;
int m_iy;
};
class line {
public:
line(int x1, int y1, int x2, int y2);
private:
Coordinate m_coorA;
Coordinate m_coorB;
};
2019-01-27
B:
//遍历输出
for (int i = 0; i < 3; i++) {
cout << "coord_x :" << "\t" << coord[i].m_ix << endl;
cout << "coord_y :" << "\t" << coord[i].m_iy << endl;
}
for (int i = 0; i < 3; i++) {
cout << "p_x:" << "\t" << p->m_ix << endl;
cout << "p_y:" << "\t" << p->m_iy << endl;
p--;
}
delete[]p;
//遍历输出
for (int i = 0; i < 3; i++) {
cout << "coord_x :" << "\t" << coord[i].m_ix << endl;
cout << "coord_y :" << "\t" << coord[i].m_iy << endl;
}
for (int i = 0; i < 3; i++) {
cout << "p_x:" << "\t" << p->m_ix << endl;
cout << "p_y:" << "\t" << p->m_iy << endl;
p--;
}
delete[]p;
2019-01-27
A:
#include"iostream"
using namespace std;
int main() {
class Coordinate {
public:
int m_ix;
int m_iy;
}coord[3] = { 3,5,2,6,3,7 };
Coordinate *p = new Coordinate[3];
//p0
p[0].m_ix = 20;
p->m_iy = 20;
p++;
//p1
p->m_ix = 6;
p[0].m_iy = 7;
//p2
p[1].m_iy = 9;
p++;
p->m_ix = 8;
#include"iostream"
using namespace std;
int main() {
class Coordinate {
public:
int m_ix;
int m_iy;
}coord[3] = { 3,5,2,6,3,7 };
Coordinate *p = new Coordinate[3];
//p0
p[0].m_ix = 20;
p->m_iy = 20;
p++;
//p1
p->m_ix = 6;
p[0].m_iy = 7;
//p2
p[1].m_iy = 9;
p++;
p->m_ix = 8;
2019-01-27