Classes & data members

Discussion in 'C++' started by ectoplasm, Oct 27, 2005.

  1. ectoplasm

    ectoplasm Guest

    I'd like to ask for advice on the following.

    I have a data structure of network elements ('NetworkElement' base
    class & derived classes like Server, Area, Cell, etc.)

    The network elements are organised under a network topology
    ('NetworkTopology' class).

    The problem is that the properties (data members) of network elements
    depend on things such as: 1) technology of the network topology, 2)
    vendor of the network element, 3) other factors.

    Is there a way to, in some way, have classes with kind of 'dynamic'
    data members which can be added / removed (in groups)?

    Bye,
    E.
    ectoplasm, Oct 27, 2005
    #1
    1. Advertising

  2. ectoplasm wrote:
    > I'd like to ask for advice on the following.
    >
    > I have a data structure of network elements ('NetworkElement' base
    > class & derived classes like Server, Area, Cell, etc.)
    >
    > The network elements are organised under a network topology
    > ('NetworkTopology' class).
    >
    > The problem is that the properties (data members) of network elements
    > depend on things such as: 1) technology of the network topology, 2)
    > vendor of the network element, 3) other factors.
    >
    > Is there a way to, in some way, have classes with kind of 'dynamic'
    > data members which can be added / removed (in groups)?
    >
    > Bye,
    > E.
    >


    No there isn't.

    To help us solve your problem you need specify more information. For
    instance do you need to add and remove these data members during the
    lifetime of a single object.

    Server s;
    s.add_group(xyz);
    s.remove_group(abc);

    etc.

    Or are you saying that each object has one particular set of data
    members that will last for the lifetime of that object, but that each
    object may have a different set of data members?

    john
    John Harrison, Oct 27, 2005
    #2
    1. Advertising

  3. ectoplasm

    mlimber Guest

    ectoplasm wrote:
    > I'd like to ask for advice on the following.
    >
    > I have a data structure of network elements ('NetworkElement' base
    > class & derived classes like Server, Area, Cell, etc.)
    >
    > The network elements are organised under a network topology
    > ('NetworkTopology' class).
    >
    > The problem is that the properties (data members) of network elements
    > depend on things such as: 1) technology of the network topology, 2)
    > vendor of the network element, 3) other factors.
    >
    > Is there a way to, in some way, have classes with kind of 'dynamic'
    > data members which can be added / removed (in groups)?
    >
    > Bye,
    > E.


    You might be interested in "virtual data" that can be simulated in C++.
    See the FAQ:

    http://www.parashift.com/c -faq-lite/value-vs-ref-semantics.html#faq-31.2

    Cheers! --M
    mlimber, Oct 27, 2005
    #3
  4. ectoplasm

    Jim Langston Guest

    "ectoplasm" <> wrote in message
    news:...
    > I'd like to ask for advice on the following.
    >
    > I have a data structure of network elements ('NetworkElement' base
    > class & derived classes like Server, Area, Cell, etc.)
    >
    > The network elements are organised under a network topology
    > ('NetworkTopology' class).
    >
    > The problem is that the properties (data members) of network elements
    > depend on things such as: 1) technology of the network topology, 2)
    > vendor of the network element, 3) other factors.
    >
    > Is there a way to, in some way, have classes with kind of 'dynamic'
    > data members which can be added / removed (in groups)?
    >
    > Bye,
    > E.


    Why not simply make the network elements polymorphic data contained in the
    NetworkTopology perhaps in a vector?

    std::vector<NetworkElement*> NetElements;

    then you can push whatever types you want into it depending on the type of
    network (perhaps in the constructor via pass in parm stating the network
    type).
    Jim Langston, Oct 30, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JFCM
    Replies:
    4
    Views:
    5,732
  2. CoolPint
    Replies:
    8
    Views:
    973
    Jeff Schwab
    Dec 14, 2003
  3. Dave
    Replies:
    3
    Views:
    363
    tom_usenet
    Aug 10, 2004
  4. Daz
    Replies:
    5
    Views:
    582
  5. Rit
    Replies:
    23
    Views:
    938
    Mike Schilling
    Jan 3, 2010
Loading...

Share This Page