class [C++ Reference]
Keywords: keywords,class
Date: 2008-10-14T15:42:04-0700

[[class]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## class

Syntax:

        class class-name : inheritance-list {
        private-members-list;
        protected:
        protected-members-list;
        public:
        public-members-list;
        } object-list;

The class keyword allows you to create new classes. class-name is the name of the class that you wish to create, and inheritance-list is an optional list of classes inherited by the new class.

Members of the class are private by default, unless listed under either the protected or public labels. object-list can be used to immediately instantiate one or more instances of the class, and is also optional.

For example:

         class Date {
           int Day;
           int Month;
           int Year;
         public:
           void display();
         };

Related Topics: friend, private, protected, public, struct, this, typename, union, virtual

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •