Practical C Programming, 3rd Edition

I l @ ve RuBoard

In C++ a structure is just like a class, except that all the data fields and member functions are public. For example, the following two are the same:

struct data { int status; int data; void start( ) { status = 1; } };

public data { public: int status; int data; void start( ) { status = 1; } };

As you can see, a structure is merely a class with all the protections removed. This means that in most cases a class is superior to a structure.

In actual practice, most programmers use structures for data only. You'll hardly ever see a structure with member functions.

I l @ ve RuBoard

Категории