Structures

A structure is created using the keyword struct. In C++, a structure also defines a class. The only difference between class and struct is that, by default, all members of a structure are public. To make a member private, you must use the private keyword. The general form of a structure declaration is like this:

struct struct-name : inheritance-list {
 // public members by default
protected:
 // private members that can be inherited
private:
 // private members
} object-list;

In C, several restrictions apply to structures. First, they may contain only data members; member functions are not allowed. C structures do not support inheritance. Also, all members are public and the keywords public, protected, and private are not allowed.




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net