Class and Container

Discussion in 'C++' started by Michael, Aug 5, 2006.

  1. Michael

    Michael Guest

    Hi,

    In real world, when to use class, container, class & container? It
    seems to me that container is more useful to number chain, class is for
    implementing complex porjects? Right? Please give your insights.

    Thanks in advance,
    Michael
     
    Michael, Aug 5, 2006
    #1
    1. Advertising

  2. * Michael:
    >
    > In real world, when to use class, container, class & container? It
    > seems to me that container is more useful to number chain, class is for
    > implementing complex porjects? Right? Please give your insights.


    In C++ a container is a class.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Aug 5, 2006
    #2
    1. Advertising

  3. Michael

    Michael Guest

    Alf P. Steinbach wrote:
    > * Michael:
    > >
    > > In real world, when to use class, container, class & container? It
    > > seems to me that container is more useful to number chain, class is for
    > > implementing complex porjects? Right? Please give your insights.

    >
    > In C++ a container is a class.
    >
    > --
    > A: Because it messes up the order in which people normally read text.
    > Q: Why is it such a bad thing?
    > A: Top-posting.
    > Q: What is the most annoying thing on usenet and in e-mail?


    Sorry for not clarifying my questions. I would like to know when shall
    I create my own class or use STL container?

    Thanks,
     
    Michael, Aug 5, 2006
    #3
  4. * Michael:
    > [quoting signature]]


    Please don't quote signatures -- corrected.


    * Michael:
    > Alf P. Steinbach wrote:
    >> * Michael:
    >>> In real world, when to use class, container, class & container? It
    >>> seems to me that container is more useful to number chain, class is for
    >>> implementing complex porjects? Right? Please give your insights.

    >> In C++ a container is a class.

    >
    > Sorry for not clarifying my questions. I would like to know when shall
    > I create my own class or use STL container?


    Should you choose the blonde or the brunette, that's the question.
    Well, if you absolutely feel you have to choose one or the other, try
    both, and choose the one that pleases you the most, or, be more
    pragmatic and choose both. ;-) Seriously.

    Generally the purpose of a class is to maintain a class invariant, a set
    of relationships between the instance data members. The class invariant
    is established by the class' constructor and maintained by every public
    member function.

    If a standard container doesn't give you the class invariant you want,
    then a custom class is called for.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Aug 5, 2006
    #4
  5. Michael

    osmium Guest

    "Michael" writes:

    > In real world, when to use class, container, class & container? It
    > seems to me that container is more useful to number chain, class is for
    > implementing complex porjects? Right? Please give your insights.


    You write your own class when you can't find an STL container that does what
    you want. Hideously complex projects can be done with just the STL and C++
    or even just C++ or even just C so complexity is of no use as a metric. .
     
    osmium, Aug 5, 2006
    #5
  6. Michael

    Daniel T. Guest

    "Michael" <> wrote:

    > In real world, when to use class, container, class & container? It
    > seems to me that container is more useful to number chain, class is for
    > implementing complex porjects? Right? Please give your insights.


    Maybe if you gave some examples where you think either a class or
    container could be used, and we can tell you what we would use in that
    situation.
     
    Daniel T., Aug 5, 2006
    #6
  7. Michael

    David Harmon Guest

    On 5 Aug 2006 10:34:34 -0700 in comp.lang.c++, "Michael"
    <> wrote,
    >Sorry for not clarifying my questions. I would like to know when shall
    >I create my own class or use STL container?


    I prefer to use the STL container classes whenever they fulfill the
    requirements of the program.
     
    David Harmon, Aug 5, 2006
    #7
    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. Vivi Orunitia
    Replies:
    11
    Views:
    4,530
    Martijn Lievaart
    Feb 4, 2004
  2. Maitre Bart
    Replies:
    2
    Views:
    539
    Maitre Bart
    Feb 11, 2004
  3. Steven T. Hatton
    Replies:
    4
    Views:
    3,959
    Rob Williscroft
    Dec 5, 2004
  4. Replies:
    4
    Views:
    826
    Daniel T.
    Feb 16, 2006
  5. wolverine
    Replies:
    2
    Views:
    469
    Marcus Kwok
    Jul 24, 2006
Loading...

Share This Page