⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graph.cc

📁 做为SD0609的一员,我扎实的基础是如何打出来的,来看看我那时连猴子选大王都不会的人,是如何成长起来的吧!主要包括我所做的C++,JAVA基础联系.乱是乱了点,不过如果真心想学习,打好基础,看看也不
💻 CC
字号:
#include <iostream>using namespace std;class Graph{protected:	int x;	int y;public:	Graph(int x=0, int y=0)	:x(x),y(y)	{}	virtual void input();	virtual void draw()=0;	virtual ~Graph(){}};void Graph::input(){	cout << "input x and y:";	cin >> x >> y;}class Line : public Graph{protected:	int endx;	int endy;public:	Line( int a=0, int b=0, int c=0, int d=0 )	:Graph(a,b),endx(c),endy(d)	{}	virtual void input();	virtual void draw();	virtual ~Line(){}};void Line::input(){	cout << "Line, ";	Graph::input();	cout << "input x and y of endpoint:";	cin >> endx >> endy;}void Line::draw(){	cout << "Line:(" << x << ',' << y << ")-(" << endx << ',' << endy << ')' << endl;}class Circle : public Graph{protected:	int r;public:	Circle(int a=0, int b=0, int c=0)	:Graph(a,b),r(c)	{}	void input();	void draw();	~Circle(){}};void Circle::input(){	cout << "Circle, ";	Graph::input();	cout << "input radius:";	cin >> r;}void Circle::draw(){	cout << "Circle:(" << x << ',' << y << ")*" << r << endl;}int main(int argc, char* argv[]){	Line ol;	Circle oc;	Graph* p=NULL;	p = &ol;	p->input();	p->draw();	p = &oc;	p->input();	p->draw();	for(;;)	{		cout << "(1)Line\t(2)Circle" <<endl;		cout << "choose 1 or 2:";		int choice;		cin >> choice;		if( choice==1 )			p = new Line;		else if( choice==2 )			p = new Circle;		else			return 0;		p->input();		p->draw();		delete p;	}	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -