| You are here: | About>Computing & Technology>C / C++ / C#> C++> Learn C++ Programming> Introduction to C++ Classes and Objects |
![]() | C / C++ / C# |
Learn about C++ Classes and ObjectsStarting with C++ classesObjects are the biggest difference between C++ and C. One of the earliest names for C++ was C with Classes.
Classes and ObjectsA class is a definition of an object. It's a type just like int. A class resembles a struct with just one difference : all struct members are public by default. All classes members are private.Remember : A class is a type, and an object of this class is just a variable. Before we can use an object, it must be created. The simplest definition of a class is class name {This example class below models a simple book. Using OOP lets you abstract the problem and think about it and not just arbitrary variables. // example oneAll the code from class book down to the int Book::GetCurrentPage(void) { function is part of the class. The main() function is there to make this a runnable application. On the next page : Understanding the example.
Previous | Next >> |
Las Vegas on a BudgetFind a BargainHotel DealsCheap EatsFree AttractionsEntertainment for Less |
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


