// C++123.cpp : 此文件包含 “main” 函数。程序执行将在此处开始并结束。
//
#include “pch.h”
#include
using namespace std;
class cube {
public:
long color;
double x, y, z, side;
};
class ADT {
public:
long color;
double x=1, y, z, side;
int a[10];
char *s;//指针
// char r = 1;// 问题:“ADT::r”:“char &”与“char”的间接寻址级别不同
// char &r;//引用 问题:“ADT::ADT(void)”: 尝试引用已删除的函数
typedef point* lppoint;
void *p;
};
class point {
public:
void set(int a, int b) {
x = a;y = b;
};
int x, y;
};
class line {
public:
void set(point a, point b) {
start = a;end = b;
};
void xprint() {
cout << start.x << “—until—” << end.x << endl;
}
void yprint() {
cout << start.y << “—until—” << end.y << endl;
}
point start, end;//成员对象
//void paint() {
// for (int x = 0; x >= start.x&&x <= end.x; x++) {
// for (int y = 0; y >= start.y&&y <= end.y; y++) {
// cout << "*";
// }
// cout << "*" << endl;
// }
// //m.set(1, 2);
// //n.set(4, 5);
//}; //没办法画出来
};
int main()
{
//例1
cout << “---------------------” << endl;
cube a;
a.x = 1;
cout << a.x << endl;
//例2
cout << “---------------------” << endl;
ADT b;
b.a[0] = 1;
cout << b.a[0] << endl;
//例3
cout << “---------------------” << endl;
point m,n;
m.set(1, 2);
n.set(4, 5);
line hang;
hang.set(m, n);
hang.xprint();
hang.yprint();
//例4
cout << “---------------------” << endl;
//hang.paint();
}