Abstract and concrete classes in c++

Discussion in 'C++' started by Anitha, Feb 1, 2005.

  1. Anitha

    Anitha Guest

    What are abstract classes and concrete classes
    Anitha, Feb 1, 2005
    #1
    1. Advertising

  2. Anitha

    Guest

    Anitha wrote:
    > What are abstract classes and concrete classes


    An abstract class is one which defines an interface, but it may not
    provide implementations for all its member functions. Generally an
    abstract class is used as the base class from which other classes are
    derived. The derived class provides implementations for the member
    functions that are not implemented in the base class.
    A derived class that implements all the missing functionality is called
    a concrete class
    , Feb 1, 2005
    #2
    1. Advertising

  3. Anitha

    Guest

    A concrete class is used to define a useful object that can be
    instantiated as an automatic variable on the program stack. The
    implementation of a concrete class is defined. The concrete class is
    not intended to be a base class and no attempt to minimize dependency
    on other classes in the implementation or behavior of the class
    , Feb 1, 2005
    #3
  4. Anitha

    Shan Guest

    Anitha wrote:
    > What are abstract classes and concrete classes

    Get a good C++ book and study it before posting...
    Shan, Feb 1, 2005
    #4
  5. Anitha

    Dave Moore Guest

    <> wrote in message
    news:...
    > A concrete class is used to define a useful object that can be
    > instantiated as an automatic variable on the program stack. The
    > implementation of a concrete class is defined. The concrete class is
    > not intended to be a base class


    No, this is not true ... concrete classes can certainly be used as base
    classes in a properly designed C++ program. A concrete class typically
    represents an particular implementation of the concepts expressed in a given
    abstract interface class. However, it may be appropriate to implement only
    part of the interface in a particular concrete class, which will then be
    used as a base class for types further down the hierarchy. It all depends
    on what you want to do.

    Advice to the OP: google the subject line, and then check out the book
    reviews at www.accu.org and buy a book to help you further.

    HTH,

    Dave Moore
    Dave Moore, Feb 1, 2005
    #5
  6. Anitha

    Jerry Coffin Guest

    Dave Moore wrote:

    [ ... ]

    > No, this is not true ... concrete classes can certainly be used as

    base
    > classes in a properly designed C++ program.


    How do you implement operator= safely for this situation?

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
    Jerry Coffin, Feb 1, 2005
    #6
  7. Anitha

    Howard Guest

    "Jerry Coffin" <> wrote in message
    news:...
    > Dave Moore wrote:
    >
    > [ ... ]
    >
    >> No, this is not true ... concrete classes can certainly be used as

    > base
    >> classes in a properly designed C++ program.

    >
    > How do you implement operator= safely for this situation?
    > Jerry.


    I'm lost as to what you're trying to get at here. What problem do you
    foresee with implementing the = operator for non-abstract classes? I have
    many classes that have no pure virtual functions. Yet I implement the =
    operator wherever I need it. How are the two issues related?

    -Howard
    Howard, Feb 1, 2005
    #7
  8. Anitha

    Dave Moore Guest

    "Jerry Coffin" <> wrote in message
    news:...
    > Dave Moore wrote:
    >
    > [ ... ]
    >
    > > No, this is not true ... concrete classes can certainly be used as

    > base
    > > classes in a properly designed C++ program.

    >
    > How do you implement operator= safely for this situation?
    >


    Well, if your base class has a copy assignment that can throw, then you
    cannot write a copy-assignment operator that satisfies the "strong
    guarantee" wrt exception safety. There is of course also a item in Scott
    Meyers "More Effective C++" entitled "Make all non-leaf classes abstract",
    which refutes my claim. So, I probably over-qualified my initial statement
    by saying "properly designed C++ program", because strong exception safety
    might be a requirement for "proper design" in many cases.

    The fact is that I myself do not require the strong guarantee for my own
    applications (scientific, numerical programs for which I am currently the
    only user), and so I don't always think in terms of strong exception safety.
    I will consider myself reprimanded 8*).

    Actually this brings up a question ... If all of the data members in a class
    (including any base classes) are statically allocated objects of built-in
    type (i.e. no pointers or ctors), then does the implicitly generated copy
    assignment operator implicitly provide the strong guarantee? Or even
    better, the no-throw guarantee? It seems like it should, because the "only
    thing that can go wrong" during construction in such a case is a stack
    overflow (in which case we are dead anyway), or am I oversimplifying things.

    Dave Moore
    Dave Moore, Feb 1, 2005
    #8
    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. DaKoadMunky
    Replies:
    4
    Views:
    547
    Lee Weiner
    Apr 20, 2004
  2. Wat
    Replies:
    2
    Views:
    597
    Cy Edmunds
    Dec 4, 2004
  3. David Baelde

    Abstract and concrete syntax

    David Baelde, Jun 9, 2005, in forum: Python
    Replies:
    19
    Views:
    469
    David Baelde
    Jun 11, 2005
  4. Replies:
    5
    Views:
    369
  5. Manuel
    Replies:
    8
    Views:
    634
    Manuel
    Jan 5, 2006
Loading...

Share This Page