Search the web
Sign In
New User? Sign Up
cuLUG · Cairo University Linux User Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
C++ question   Message List  
Reply | Forward Message #1691 of 1764 |
Re: [cuLUG] C++ question

السلام عليكم و رحمة الله و بركاته

You cannot instantiate a an abstract class. This is not only a technical constraint but in fact a conceptual one.

So why do you want to pass the drawable object by reference ? Maybe for protection ?
In this case you can use reference to const:
int registerObject(const DrawableObject& dObject);


On Mon, May 12, 2008 at 10:16 PM, Ali Helmy <alihelmy@...> wrote:
Hey mates,

Ive got this abstract class, DrawableObject that has just one func (of interest to this mail) which is

class DrawableObject
{
virtual void draw() = 0;
};

now, i have another class, that is GfxEngine and it has one func, 

class GfxEngine
{
int registerObject(DrawableObject& dObject);
};

now here is my dilemma, if i keep the drawable object abstract, then i cannot pass it by value to the gfx engine func, since i cannot instantiate it, ie: the func signature cannot be int registerObject(DrawableObject dObject), and i do not want to pass it by reference, so... any ideas?

---
Cheers,
seth
<A. Helmy>
One life... LIVE it!



--
Ahmed Said Hefny
Cairo University
Faculty of Engineering
Computer Engineering Department

Mon May 12, 2008 8:08 pm

cyber_modiko
Offline Offline
Send Email Send Email

Forward
Message #1691 of 1764 |
Expand Messages Author Sort by Date

Hey mates, Ive got this abstract class, DrawableObject that has just one func (of interest to this mail) which is class DrawableObject { virtual void draw() =...
Ali Helmy
sethdarkenmore
Offline Send Email
May 12, 2008
7:16 pm

السلام عليكم و رحمة الله و بركاته You cannot instantiate a an abstract class. This is not only a technical constraint but in fact a...
Ahmed Hefny
cyber_modiko
Offline Send Email
May 12, 2008
8:08 pm

... ya raaaaaaaaaaaaaaaaaaaaaaaaaaagel? eih dah fe3lan? makontesh 3aref khales... harou7 2a2ra learn visual c++ in 21 days tany.. ... Maybe i wasnt clear... so...
Ali Helmy
sethdarkenmore
Offline Send Email
May 13, 2008
6:05 pm

Ali.....How are you? I guess Hefny replied your question, he just forgot a "not" [Typing mistake]. Let me rephrase: So why do*n't* you want to pass the...
Safey allah Mohammed
yaraber7amni
Offline Send Email
May 13, 2008
6:41 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help