home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!spool.mu.edu!yale.edu!yale!gumby!destroyer!cs.ubc.ca!utcsri!newsflash.concordia.ca!nstn.ns.ca!dragon.acadiau.ca!870086t
- From: 870086t@dragon.acadiau.ca (Shannon Tremblay)
- Subject: object classes
- Message-ID: <1992Nov9.172651.10696@dragon.acadiau.ca>
- Keywords: Object, DoubleList
- Organization: Acadia University
- Date: Mon, 9 Nov 1992 17:26:51 GMT
- Lines: 88
-
-
-
- hi all,
-
- I am trying to build a graphics editor. Just the basic shapes, each one
- to be treated as an object.
- Sounds like a simple task, right? I thought so.
- Here is a sample of my class definitions. I have left out some parameters
- in some of the functions for simplicity.
-
-
- //
- //Sample Code
- //
-
- class Shape : public Object
- {
- public:
- Shape();
- ~Shape();
-
- virtual char* nameOf(); // pure virtual members
- virtual classType isA(); // from class Object
- virtual void printOn( ostream& );
- virtual hashType hashValue();
-
- virtual void Draw();
- virtual void Assign();
- private:
- int figure,
- color,
- style;
- };
-
- class Square : public Shape
- {
- public:
- Square();
- ~Square();
- void Draw();
- void Assign();
- private:
- int x1, x2, y1, y2;
- };
-
- class Circle : public Shape
- {
- public:
- Circle();
- ~Circle();
- void Draw();
- void Assign();
- private:
- int x1, x2, y1, y2;
- };
-
-
- class ObjectList : public DoubleList
- {
- public:
- ObjectList();
- ~ObjectList();
- add(Object&);
- detach(Object&, DeleteType);
- void Display();
- private:
- BOOL dirty; // just marks when an object is touched in some way.
- };
-
-
-
- I believe I have the objects adding onto the list properly, but I can not
- iterate through the list of object inorder to refresh the screen when needed.
- Also when I return something it is of type Object and therefore I loose
- the member functions I created under Shape.
-
- Does anyone know of source code that would demonstrate to me how to go about
- creating an object, placing it in a list, and then being able to retrieve
- the object, intact, as it was placed on the list, that is derived members
- still avialable. As well as being able to iterate through the list,
- accessing the derived functions as I go.
-
- Or am I expecting too much??? I didn't think so...
-
- thanks in advance
-
- shannon.tremblay@acadiau.ca
-
-