Share this post

Link to post

Share on other sites

Well, let''s see... An abstract class, by definition is simply a class that has one or more pure virtual functions. Also, objects cannot be created from an abstract class (though you can create a pointer to an abstract class), but other classes can be derived from them. As far as their use, their great for creating a common object interface (much the way interfaces are used in Java). With all this in mind, you could have a pointer to an abstact class pointing to a list of objects derived from that class. They would all have a function that they all would inherit from that abstract base class, but you would be able to define each function differently. Thus, each derived class could act in a completely different way than other classes derived from that base abstract class when the same function is called for each.

Share this post

Link to post

Share on other sites

Guest Anonymous Poster

Guest Anonymous Poster

The concept behind abstraction is to separate interfaces from implementation so that each vary separately so that you can more easily intermix related and un-related classes/objects/components

this is to :1) promote re-use2) when classes are very tightly coupled fixes or interfaceor implementation changes lead to problems in other classes(this can be anything from improper working (ie instead of Effect A (expected) you get Effect B (unexpected))to being forced to re-compile as the other classes interface has changed so significantly ''yours'' no longer works (this can be a nightmare if you were relying on an external library whose interface changed between versions)

also, consider portability issues ..you are using DirectX on windows, you want to port your app to OpenGL on *n?x if you create an abstraction of hardware rendering (in my lib this is an abstract class called ''Renderer'')then you implement 2 separte versions of Renderer for DX and Opengl then your app can decide (at run-time) which implementation to go with (you will of course need to create a few other abstractions, for window-creation, and whatnot)but what you have done is made it significantly simpler for potential future expansion , even expansion you may not have originally planned for (and if you''re a library writer, it can very well be expansion that you had not intended and someoneelse could take your library and expanded it to some platform or implementation you had not considered)

on the concepts of abstraction, good object-oriented abstractionand how it relates to computer games, i recommend these 3 books

Share this post

Link to post

Share on other sites

"The process of picking out (abstracting) common features of objects and procedures. A programmer would use abstraction, for example, to note that two functions perform almost the same task and can be combined into a single function. Abstraction is one of the most important techniques in software engineering and is closely related to two other important techniques -- encapsulation and information hiding. All three techniques are used to reduce complexity."