<NOSCRIPT><A href="http://about.com/" target=_blank><IMG src="C++ Tutorial - Lesson 33 Abstract Data Types_files/0.gif" border=0></A></NOSCRIPT>   About > Computing & Technology > C/C++ 
Search     
 Hi, I'm John Kopp, your guide to C, C++ and C# programming. This site provides what you need to know to learn C, C++ or C# programming. Browse the subjects on the left, try one of the tutorials or use the search box to get started.

C/C++

with John Kopp
Your Guide to one of hundreds of sites
 Home · Articles · Forums · Chat · Newsletters · Help    
Subjects

  ESSENTIALS
· C Tutorial
· C++ Tutorial
· C/C++ Glossary
· Tips
· More Tutorials
  BUYER'S GUIDE

Product Reviews
Top Picks
C Tutorials
C++ Tutorials
C#
Advanced C
Advanced C++
Beginning C
Beginning C++
Books
C++ Builder
Careers
CGI
CM
Dictionaries
CompilingDebugging
Freeware/Shareware
Humor
Magazines
OOAD
Polls
SoftwareEngineer'n
Style
STL
UNIX/GNU
Visual C++

Subject Library

All articles on this topic

 

Stay up-to-date!
Subscribe to our newsletter.

Web Hosting
Global Servers

 
 
 
Advertisement
> Free Credit Report
 
C++ Tutorial - Lesson 33: Abstract Data Types
 More of this Feature
• Introduction
• Abstract Data Types
• Implementations for Pure Virtual Functions
 
 Related Resources
• Inheritance
• Polymorphism
• Multiple Inheritance
• Virtual Inheritance
• Advanced C++ Tutorials
• Simple Solutions in C++
• C++ Programming Tips
• C++ Tutorial, All Lessons
 

by John Kopp

Introduction
Welcome to About.com's free tutorial on C++ programming. This lesson covers abstract data types and pure virtual functions. An abstract data type is a class that is meant to serve only as an interface for derived classes; it cannot be instantiated. They serve as base classes to other classes that will be instantiated into objects. In earlier lessons, we saw the role of virtual functions in allowing polymorphism in our code. In C++, a pure virtual function is not only intended to be overridden in base classes, it must be. Pure virtual functions provide a way to force derived classes to implement a particular interface.

Let's return to our Vehicle and Car classes of the last few lessons. Conceptually, the Vehicle class should be an abstract data type. It's possible to drive a Car, accelerate a Car, decelerate a Car, but not a Vehicle. A vehicle is an abstraction, or concept. A Car can be a concrete object that we can use to achieve some end in either our software world or the physical world. If a vehicle can't be concrete, if it can't be instantiated, what's its purpose? It serves as a model of the abilities and properties a Car will have. A vehicle can provide implementations for some of these abilities through its non-virtual and non-pure virtual methods. It can also provide only an interface for other methods through the use of pure virtual functions. The interface of a method refers to the number and type of arguments and to the return type; it is what the outside world, other classes need to know to use the function. It describes what they must provide and what to expect back.

Next page > Abstract Data Types > Page 1, 2, 3


Subscribe to the C/C++ Newsletter
Name
Email






Email this page | Sign up for a Newsletter |
Explore More
Most Popular Articles
• C++ Programming Tutorial
• C Programming Tutorial
• C++ Tutorial - Lesson 12: File Input and Output
• C++ Tutorial - Lesson 4: Input and Output - cin, cout, iostr...
• C++ Tutorial - Lesson 10: Arrays and Vectors
• C++ Tutorial - Lesson 1: Writing and Compiling A First Progr...
• Tutorials
What's Hot Now
• Teach Yourself C++ in 21 Days by Jesse Liberty
• C Programming Tutorial
• C++ Tutorial - Lesson 25: Operator Overloading
• The C Programming Language, 2nd Edition by Kernighan and Rit...
• Topics in C++: Function Template Specialization
• C Programming Tips: Using Long Constants
• C Tutorial - Lesson 5: Conditional Processing, Part 1 - Rela...
About Us | Advertise on This Site | User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2004 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.