UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C++
  • » design pattern question

#1 2007-02-26 03:35 PM

yurec
Member
From: Singapore
Registered: 2006-11-16
Posts: 134

Re: design pattern question

Hi

class A
{
  class B * p;//In some way call p = new (class that extedns B)();
}

class B
{
   class C * p;//In some way call p = new (class that extedns C)();
}

class C
{
  class D * p;//In some way call p = new (class that extedns D)();
}
....
//and so on
class X
{
  class Y * p;//In some way call p = new (class that extedns Y)();
  virtual void foo();
}
....
//and so on


If I want to ovverride some virtual function in such chunk of classes, each creating another,I have to do use inheritance for each class, that is above class X in the hierarchy.Or use templates

int main()
{
  A<(class that extends B<class that extends C<(.. and so on up to class that extends class X)>)>)> a;
  return 0;
}


I understand that It might be hard to understand the question..
So thanks even for attempt to do it.

Offline

#2 2007-02-26 04:33 PM

yurec
Member
From: Singapore
Registered: 2006-11-16
Posts: 134

Re: design pattern question

Maybe the simplest decision is to use some class,that has fucntions to create an instance of each class in the chunk?

Offline

#3 2007-03-10 07:20 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: design pattern question

Um - I don't think I understand the question...

Maybe it would be better if you described the 'task' the code is meant to accomplish... that might make it easier... ?


Michael


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#4 2007-03-12 12:42 PM

yurec
Member
From: Singapore
Registered: 2006-11-16
Posts: 134

Re: design pattern question

If there is a class that creates another class, which in its turn creates another class it can be hard to change behavoiur of the first class via overriding some virtual functions of the last class.I'm going to decide this problem using a kind of factory,that can create instances of any class.I think it can be very simple and easy to implement.

Offline

#5 2008-05-31 04:12 PM

domutadrian
Guest

Re: design pattern question

  • Index
  • » C++
  • » design pattern question

Board footer

Powered by FluxBB