Author Topic: derived classes  (Read 1995 times)

zlotin

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
derived classes
« on: January 10, 2002, 04:31:08 am »
I have the followed class hierarchy:
class A
{
    virtual void f1()=0;
    virtual void f2()=0;
};

class b
{
    virtual void f1() {} ;
};
class c
{
    virtual void f2() {} ;
};

How can I draw class diagram for this code?

When I tried to implement it, I got ( after export the code):
class A
{
     B * m_B;  

     virtual f1() =0;
     virtual f2() =0;
};

class B : public A
{
     C * m_C;

public:
     B();
     virtual ~B();
     virtual f1() =0;
     virtual f2() =0;

};

class C : public B
{
     B * m_B;

public:
     C();
     virtual ~C();
};

zlotin

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: derived classes
« Reply #1 on: January 10, 2002, 05:36:41 am »
sorry... mistaken...

class A
{
   virtual void f1()=0;
   virtual void f2()=0;
};

class b : public A
{
   virtual void f1() {} ;
};
class c : public b
{
   virtual void f2() {} ;
};
classes should be derived one from other...

gsparks

  • EA User
  • **
  • Posts: 325
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: derived classes
« Reply #2 on: January 13, 2002, 02:34:26 pm »
Lev,

I think the easiest way to explain is to explain is to place your class hierarchy in a single .h file and reverse engineer into EA. I did this, then forward engineered into new .h files - the only change was the addition of constructor/destructor - otherwise the code was the same.

If you do this you should be able to see how the operations etc. are configured. From the code you generated previously it sounds like you have added an association link netween classes, as well as a generalization, resulting in an instance variable for the associated class.

Geoff Sparks



Lev  Zlotin

  • Guest
Re: derived classes
« Reply #3 on: January 14, 2002, 03:40:26 am »
No import was done. I drawed the classes in the EA and exported it after that ( I do not know how to insert diagram here, so I described it by the classes which I wanted to draw ). I added no associations, only generalizations.

P.S. In the new version you draw the connections as directed by default, but in export they have two directions anyway. I seen such a problem a number of times.

gsparks

  • EA User
  • **
  • Posts: 325
  • Karma: +0/-0
  • I love YaBB 1 Gold!
    • View Profile
Re: derived classes
« Reply #4 on: January 14, 2002, 07:41:43 pm »
Hi Lev,

I drew three classes (in build 443) as you described - the code generated matches what you originally asked about - with the excpetion of the inline empty function bodies. If you like I can send you a model with this example in it - or some XML to import.


ClassA - root class with two Abstract/Pure operations ... code generated is:

class ClassA
{
public:
     ClassA();
     virtual ~ClassA();
public:
     virtual void f1() =0;
     virtual void f2() =0;
};

I then create ClassB and draw inheritance link to ClassA - ClassB has one Abstract operation - code generated:

#include "ClassA.h"

class ClassB : public ClassA
{
public:
     ClassB();
     virtual ~ClassB();
public:
     virtual void f2();
};


I then draw another class - ClassC. Make ClassC a child of ClassB using inheritance link. ClassC also has one Abstract operation. Code is:

class ClassC : public ClassB
{
public:
     ClassC();
     virtual ~ClassC();
public:
     virtual void f1();
};