abstract class

Discussion in 'C++' started by sam_cit@yahoo.co.in, Jan 6, 2007.

  1. Guest

    Hi Everyone,

    We know that objects of Abstract class can't be created and functions
    of abstract class have to be overriden by the child class, so this
    makes me think as to what is the use of having a abstract class in
    programming?

    Thanks in advance
     
    , Jan 6, 2007
    #1
    1. Advertising

  2. Ondra Holub Guest

    napsal:
    > Hi Everyone,
    >
    > We know that objects of Abstract class can't be created and functions
    > of abstract class have to be overriden by the child class, so this
    > makes me think as to what is the use of having a abstract class in
    > programming?
    >
    > Thanks in advance


    Abstract class gives to the user some interface which must be
    fulfilled. The requirement to overwrite some functions forces the user
    of class to provide required interface.
     
    Ondra Holub, Jan 6, 2007
    #2
    1. Advertising

  3. On Jan 6, 1:11 pm, wrote:
    > Hi Everyone,
    >
    > We know that objects of Abstract class can't be created and functions
    > of abstract class have to be overriden by the child class, so this
    > makes me think as to what is the use of having a abstract class in
    > programming?
    >
    > Thanks in advance


    It allows abstraction to take place.

    The entire code base can now know only about the Abstract class and use
    its virtual methods.
    There can then be only one small place where the real concrete classes
    that derive from them, need be specifiied and used.

    Its certainly very useful for APIs, where you want your 3rd party
    library to be useful by others, without them having to know which
    specific concrete classes to use. This flexablity creates numerous
    benefits....

    Andrew
     
    andrewmcdonagh, Jan 6, 2007
    #3
  4. Jim Langston Guest

    <> wrote in message
    news:...
    > Hi Everyone,
    >
    > We know that objects of Abstract class can't be created and functions
    > of abstract class have to be overriden by the child class, so this
    > makes me think as to what is the use of having a abstract class in
    > programming?
    >
    > Thanks in advance


    I made an abstract class for someone today to show him some things and I
    think he'll actually use it wth modificaton in production code.

    The abstract class is a base class for a polymophic type that he will have a
    vector of. Even though the abstract base class can't be instatized, the
    derived classes can. And a base class is required for polymorphism. That's
    what I normally use them for anyway.
     
    Jim Langston, Jan 6, 2007
    #4
  5. Daniel T. Guest

    wrote:

    > We know that objects of Abstract class can't be created and functions
    > of abstract class have to be overriden by the child class, so this
    > makes me think as to what is the use of having a abstract class in
    > programming?


    http://www.objectmentor.com/resources/articles/ocp.pdf
     
    Daniel T., Jan 6, 2007
    #5
  6. Grizlyk Guest

    wrote:
    >
    > We know that objects of Abstract class can't be created and functions
    > of abstract class have to be overriden by the child class, so this
    > makes me think as to what is the use of having a abstract class in
    > programming?


    The classes are using to declare interface. From C language point of
    view, class is similar to module, so must have interface, with the help
    of which all other parts of program call the module implementation.
    Interface can have no code, as Abstract class do.

    Unlike to single C module, C++ program can have many modules with the
    same interface of the Abstract class, having equal or different
    implementation, and able to be changed at runtime without relink.

    For example, Abstract class can describe interface of video system, and
    concrete implementation of the interface can be selected at runtime by
    correct derived class.

    C++ program can have many different Abstract classes.

    See abstract data types for C language details.

    To learn desing of classes see here:

    http://groups.google.com/group/comp...d7d6535/106fd67b957cf34b#doc_848d7705920c8533
    and next message
     
    Grizlyk, Jan 12, 2007
    #6
    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. Matthias Kaeppler
    Replies:
    1
    Views:
    443
    R.F. Pels
    May 22, 2005
  2. Sameer
    Replies:
    4
    Views:
    604
    Roedy Green
    Aug 31, 2005
  3. Uzytkownik
    Replies:
    3
    Views:
    594
    Uzytkownik
    Apr 3, 2005
  4. Iyer, Prasad C

    Abstract Methods & Abstract Class

    Iyer, Prasad C, Oct 20, 2005, in forum: Python
    Replies:
    0
    Views:
    534
    Iyer, Prasad C
    Oct 20, 2005
  5. Replies:
    4
    Views:
    821
    Rolf Magnus
    May 17, 2006
Loading...

Share This Page