Click here to Skip to main content
15,887,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralMFC 7.0 and 98 Pin
Anonymous6-Jan-04 1:49
Anonymous6-Jan-04 1:49 
GeneralRe: MFC 7.0 and 98 Pin
Nick Hodapp6-Jan-04 4:25
sitebuilderNick Hodapp6-Jan-04 4:25 
GeneralRe: MFC 7.0 and 98 Pin
Anonymous6-Jan-04 6:20
Anonymous6-Jan-04 6:20 
GeneralMap URL address to IP address Pin
Anonymous6-Jan-04 0:16
Anonymous6-Jan-04 0:16 
GeneralRe: Map URL address to IP address Pin
Imran Farooqui6-Jan-04 1:23
Imran Farooqui6-Jan-04 1:23 
GeneralAdd to favorites Pin
Anonymous5-Jan-04 23:44
Anonymous5-Jan-04 23:44 
GeneralRe: Add to favorites Pin
ohadp6-Jan-04 1:11
ohadp6-Jan-04 1:11 
GeneralDeveloping a Basic Graphics Package Pin
Eldalie5-Jan-04 23:30
Eldalie5-Jan-04 23:30 
Hi everybody,
I've been given the following assignment: I have to develop a basic graphics packager, by using a Shape class hierarchy, I have to limit my self to 2D shapes (simple one's). The program should interact with the user, the user should specify the position, size, shape and fill characters for drawing the object. Each class has its own draw member functions.

O.K., so I want to go on things easy step by step, so I deceided to write on myself a drive program for testing purposes, which looks like this.

<br />
#include<iostream.h><br />
<br />
class Shape {<br />
protected:<br />
	char *figType;<br />
public:<br />
	Shape(char *ft = "Define Figure"):figType(ft) {<br />
		cout<<"Shape Construct"<<endl;<br />
	};<br />
	char *getType() {return figType;};<br />
	virtual double Area() {return 0.0;}; //If virtual is removed Shape applied will show 0 !<br />
};<br />
<br />
class Square:public Shape {<br />
protected:<br />
	double length;<br />
public:<br />
	Square(double l):Shape("Square") {<br />
		length = l;<br />
		cout<<"A Rectangle Object Created"<<endl;<br />
	};<br />
	double Area() {return length*length;};<br />
};<br />
<br />
class Rectangle:public Shape {<br />
protected:<br />
	double height, width;<br />
public:<br />
	Rectangle(double h, double w):Shape("Rectangle") {<br />
		height = h;<br />
		width = w;<br />
		cout<<"A Rectangle Object Created"<<endl;<br />
	};<br />
	double Area() {return height*width;};<br />
};<br />
<br />
class Triangle:public Shape {<br />
protected:<br />
	double height, base;<br />
public:<br />
	Triangle(double h, double b):Shape("Triangle") {<br />
		height = h;<br />
		base = b;<br />
		cout<<"A Triangle Object Created"<<endl;<br />
	};<br />
	double Area() {return height*base;};<br />
};<br />
<br />
class Circle:public Shape {<br />
protected:<br />
	double pir;<br />
public:<br />
	Circle(double p):Shape("Circle") {<br />
		pir = p;<br />
		cout<<"A Circle Object Created"<<endl;<br />
	};<br />
	double Area() {return pir*pir;};<br />
};<br />
<br />
void main() {<br />
	Shape *s1;<br />
	Rectangle *rp1;<br />
	Rectangle r1(3,5);<br />
<br />
	s1=&r1; //Shape pointer points to a rectangle object<br />
	rp1=&r1;//Rectangle poiter points to a rectangle object<br />
<br />
	cout<<"Area() applied through Rectangle pointer "<<rp1->Area()<<endl;<br />
	cout<<"Area() applied through Shape pointer "<<s1->Area()<<endl;<br />
};<br />


All I want to know right now is, how similar is the code to the question asked above ? Smile | :) Can I apply this structure for using OpenGL instead of using characters for drawing the objects ? And where can I get nice and easy examples ?

Thanks in advance

Tolga
GeneralRe: Developing a Basic Graphics Package Pin
ohadp6-Jan-04 1:19
ohadp6-Jan-04 1:19 
GeneralRe: Developing a Basic Graphics Package Pin
Eldalie6-Jan-04 18:10
Eldalie6-Jan-04 18:10 
GeneralDevelopi Pin
Eldalie5-Jan-04 23:30
Eldalie5-Jan-04 23:30 
GeneralGetting key presses from MFC Pin
Anonymous5-Jan-04 23:29
Anonymous5-Jan-04 23:29 
GeneralRe: Getting key presses from MFC Pin
volkan8785-Jan-04 23:50
volkan8785-Jan-04 23:50 
GeneralRe: Getting key presses from MFC Pin
Anonymous6-Jan-04 7:10
Anonymous6-Jan-04 7:10 
GeneralHelp in MDI / VC++ needed Pin
Ruchit Sharma5-Jan-04 23:27
Ruchit Sharma5-Jan-04 23:27 
GeneralRe: Help in MDI / VC++ needed Pin
2249176-Jan-04 1:50
2249176-Jan-04 1:50 
GeneralCFont class Pin
TolTol5-Jan-04 23:26
TolTol5-Jan-04 23:26 
GeneralRe: CFont class Pin
Monty26-Jan-04 1:11
Monty26-Jan-04 1:11 
GeneralRe: CFont class Pin
TolTol6-Jan-04 4:02
TolTol6-Jan-04 4:02 
GeneralProgress control using GDI+ Pin
Steve Messer5-Jan-04 21:31
Steve Messer5-Jan-04 21:31 
Generalaquiring the size of a dialog resource Pin
luddet5-Jan-04 18:59
luddet5-Jan-04 18:59 
GeneralRe: aquiring the size of a dialog resource Pin
abc8765-Jan-04 20:30
abc8765-Jan-04 20:30 
GeneralRe: aquiring the size of a dialog resource Pin
Monty25-Jan-04 20:50
Monty25-Jan-04 20:50 
GeneralRe: aquiring the size of a dialog resource Pin
luddet6-Jan-04 6:32
luddet6-Jan-04 6:32 
GeneralSMS through my app Pin
parths5-Jan-04 17:56
parths5-Jan-04 17:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.