User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Game Development section within the Software Development category of DaniWeb, a massive community of 391,590 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,685 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Game Development advertiser:
Views: 1869 | Replies: 3
Reply
Join Date: Apr 2005
Posts: 2
Reputation: Qatar is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Qatar Qatar is offline Offline
Newbie Poster

Inheritance Project ..

  #1  
Apr 28th, 2005
Hello ...


I must do a mini project on Inheritance ..
It's about 2-D and 3-D shapes..


The base class is point ..
and we must define as many derived classes as we could such as circle .. rectangle .. triangle .. Cylender .... and so on !


The most clsses and functions we include the most grades we will get ..


can you please help me in that .. Ideas ... articles .... Tutorials ... Open codes or any thing related ..


AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2004
Posts: 218
Reputation: BountyX is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 6
BountyX's Avatar
BountyX BountyX is offline Offline
Code Guru

Re: Inheritance Project ..

  #2  
Apr 29th, 2005
are you doing it in opengl? or is it like turtle graphics
A Hacker's Mind:
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes..." - J.D.Salinger
Reply With Quote  
Join Date: Apr 2005
Posts: 2
Reputation: Qatar is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Qatar Qatar is offline Offline
Newbie Poster

Re: Inheritance Project ..

  #3  
Apr 29th, 2005
It is an open project ..
the teacher didn't put any rules for it ..
Reply With Quote  
Join Date: Sep 2004
Posts: 6,017
Reputation: Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of 
Rep Power: 26
Solved Threads: 414
Super Moderator
Narue's Avatar
Narue Narue is offline Offline
Expert Meanie

Re: Inheritance Project ..

  #4  
Apr 29th, 2005
>The base class is point .
Inheritance isn't the right solution for point. A shape is not a point. A shape has one or more points, so containment is a better solution. point should be a stand-alone class. I really hate the shape abstraction as a means of introducing inheritance, but consider this:
struct Point {
  int x, y;
};

class Shape {
  /* No points */
public:
  virtual void draw() const { cout<<"Shape"<<endl; }
};

class Ellipse: public Shape {
  Point center;
  int radius;
public:
  virtual void draw() const { cout<<"Ellipse"<<endl; }
};

class Rectangle: public Shape {
  Point top_left;
  Point bottom_right;
public:
  virtual void draw() const { cout<<"Rectangle"<<endl; }
};
It's much harder to work out a coherent hierarchy if all of the shapes derive from Point.
Member of: Beautiful Code Club.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Game Development Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Game Development Forum

All times are GMT -4. The time now is 11:20 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC