This section contains 452 words (approx. 2 pages at 300 words per page) |
![]() |
A class declaration is a blueprint for what a class will look like, the data members it will contain, and the functions it will have. In C++ a class declaration is typically made in a "header file" or "include file." A class declaration is essentially an interface specification that says what a class will look like and what it does rather than how it does it.
Java does not have pure declarations like C++ does, and, indeed, it is possible in C++ to combine declaration (interface) with definition (implementation) in the same portion of code.
Take these two examples. The first is a C++ class declaration. It tells the compiler that "this is what an eggTimer looks like and what it can do":
- class eggTimer {
- public:
- int timeEgg (int t);
- private:
- void ringBell();
- };
It does not say anything about exactly how the egg will be timed...
This section contains 452 words (approx. 2 pages at 300 words per page) |
![]() |