Abstract or Interface?

This is a discussion on Abstract or Interface? within the Tech Board forums, part of the Community Boards category; Anyone know what are abstract classes and interfaces? Not as language construct but conceptually . In object oriented design matters, ...

  1. #1
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489

    Abstract or Interface?

    Anyone know what are abstract classes and interfaces?

    Not as language construct but conceptually.



    In object oriented design matters, we should separate multiple responsibilities classes.

    But how do we connect them?
    Should we use abstract classes or interfaces?

    Why do we use abstract class?
    Why do we use interface?

    Anyone know please?
    Thanks in advance.
    Just GET it OFF out my mind!!

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,663
    An abstract class is generally an interface in C++.
    It's good to use abstract classes since they often contain common functionality used by several classes. There is also no sense in being able to create an abstract class, which is why it is marked abstract, thus becoming an interface, something you cannot create an instance of, only derive from.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    Actually abstract classes == interface isn't it?

    Why do so much language separating "abstract class" and "interface" ?
    Just GET it OFF out my mind!!

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,663
    What I can say for sure is that it's called an abstract class in the language, but an interface conceptually.
    So you really call them whichever.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,487
    They are called an Interface because these classes main objective is to define a protocol, or a set of rules for other classes deriving from it to use. The abstract class itself is not meant to be instantiated.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    An abstract class can define some of it's member functions, but as long as it has at least one pure virtual function (without being defined) then it's an abstract class; an interface has all pure virtual functions (no functions are defined).

    In Java they make the distinction easier by having separate 'abstract' & 'interface' keywords.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  7. #7
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Google brings up some results.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Abstract inheritence
    By Chris87 in forum C++ Programming
    Replies: 6
    Last Post: 06-18-2009, 10:47 AM
  2. How to get RSSI value, send to sensor, sensor receive package, repackage it?
    By techissue2008 in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-04-2009, 09:13 AM
  3. Calling IRichEditOle interface methods
    By Niara in forum C Programming
    Replies: 2
    Last Post: 01-16-2009, 12:23 PM
  4. abstract class
    By xddxogm3 in forum C++ Programming
    Replies: 5
    Last Post: 01-01-2005, 08:08 AM
  5. OOP in C
    By lyx in forum C Programming
    Replies: 4
    Last Post: 11-23-2003, 12:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21