C++ 1.2例题

// 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();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值