Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>class class definition type</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 class                   Class Definition Type

  class classname [:baselist] {
     [member list] }

            Classes are the fundamental basis of C++ -- you declare
    objects with the class keyword. Objects are much like structs in C,
    except that they can also contain functions and have other
    attributes. Classes are specific to C++.
            In the definition above, classname is the name of the class
    you are creating. The option identifier baselist specifies the base
    class from which objects of type classname will inherit objects and
    methods. The list memberlist defines the classes members -- both data
    and member functions.
            By default, all members of a class are private, which means
    that they are accessible only by member functions. However, you can
    list member variables and member functions as public, like this:

            class fish {
                int num_fish;
            public:
                void increment_num_fish(void);
                void decrement_num_fish(void);
            };

            void fish::increment_num_fish(void);
            {
                num_fish++;
            }

            void fish::decrement_num_fish(void);
            {
                num_fish--;
            }

   -------------------------------- Examples --------------------------------
    This example creates a class called birdwatch.

              class birdwatch {
                 int num_finches;
                 int num_seagulls;
              public:
                 int finch_spotted(void);
                 int seagull_spotted(void);
              };

See Also: public private protected friend

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson