How to represent a chunk of Constant Data

Discussion in 'C++' started by AdamJoe1, Nov 4, 2003.

  1. AdamJoe1

    AdamJoe1 Guest

    In my application I have a Connection class which has, amongst others,
    attributes which represent a host id and port number. These must be unique
    for each Connection. I want these attributes to be initialised to values
    given by the constructor's parameters. I know in advance how many Connection
    classes I need and what the values of these attributes will be. The
    Connection class instances are created at various points during the
    intialisation phase of the application. I want to hold, in one place, all
    the possible values of host id and port number that the application can use.
    This way, whenever the need for another Connection instance arises, a new
    value can just be added to the list. I was thinking of a ConnectionDetails
    class could do this but I'm not sure how best to implement it. It may be
    that it will just contain constant data or enums. I don't want to have a
    header file full of #defines that I include all over the place. Can anyone
    help?
     
    AdamJoe1, Nov 4, 2003
    #1
    1. Advertising

  2. AdamJoe1

    David Rubin Guest

    AdamJoe1 wrote:
    > In my application I have a Connection class which has, amongst others,
    > attributes which represent a host id and port number. These must be unique
    > for each Connection. I want these attributes to be initialised to values
    > given by the constructor's parameters. I know in advance how many Connection
    > classes I need and what the values of these attributes will be. The
    > Connection class instances are created at various points during the
    > intialisation phase of the application. I want to hold, in one place, all
    > the possible values of host id and port number that the application can use.
    > This way, whenever the need for another Connection instance arises, a new
    > value can just be added to the list. I was thinking of a ConnectionDetails
    > class could do this but I'm not sure how best to implement it. It may be
    > that it will just contain constant data or enums. I don't want to have a
    > header file full of #defines that I include all over the place. Can anyone
    > help?


    Perhaps you want to hold unused Connection instances in a freelist. This
    way, you can create the Connections (all at once?) in one place, and you
    don't have to worry about spreading the various Connection attribute
    details around your code. You just ask for the next available Connection.

    /david

    --
    "As a scientist, Throckmorton knew that if he were ever to break wind in
    the echo chamber, he would never hear the end of it."
     
    David Rubin, Nov 5, 2003
    #2
    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. Darsant
    Replies:
    8
    Views:
    537
  2. Jane Austine
    Replies:
    14
    Views:
    819
    Dennis Lee Bieber
    Oct 9, 2004
  3. Jane Austine
    Replies:
    2
    Views:
    476
    Changjune Kim
    Oct 5, 2004
  4. Sanjeeb
    Replies:
    3
    Views:
    447
    Ryan Kelly
    Aug 3, 2010
  5. G G
    Replies:
    3
    Views:
    113
    Ben Bacarisse
    Apr 20, 2014
Loading...

Share This Page