|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Make headers???
Hello to Everybody,
I have the class declaration 'BOX.h', the class implementation 'BOX.cpp'
and the main routine 'BOXEN2.cpp'. How can I create a working header
file and such link the files to make them running????
Thanks a lot!
Lisa
-----------------------------------------------------------------------------
The header file, class declaration
-----------------------------------------------------------------------------
// Kapitel 5 - Programm 7 - BOX.H
class Box
{
int Laenge;
int Breite;
public:
Box(void); //Konstruktor
void Setze(int NeueLaenge, int NeueBreite);
int HoleFlaeche(void) {return (Laenge * Breite);}
~Box(void); //Destruktor
};
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
The class implementation
-----------------------------------------------------------------------------
// Kapitel 5 - Programm 8 - BOX.CPP
#include "box.h"
Box::Box(void) //Implementation des Konstruktors
{
Laenge = 8;
Breite = 8;
}
// Diese Methode setzt die Größe der Box auf die beiden Parameter
void Box::Setze(int NeueLaenge, int NeueBreite)
{
Laenge = NeueLaenge;
Breite = NeueBreite;
}
Box::~Box(void) //Implementation des Destruktors
{
Laenge = 0;
Breite = 0;
}
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
The main routine
-----------------------------------------------------------------------------
// Kapitel 5 - Programm 9 - BOXEN2.CPP
#include <iostream.h>
#include "box.h"
int main()
{
Box Klein, Mittel, Grosz; //Drei Boxen
Klein.Setze(5, 7);
// Die mittlere Box verwendet die Werte,
// die der Konstruktor vorgibt
Grosz.Setze(15, 20);
cout << "Der Flaecheninhalt der keinen Box ist " <<
Klein.HoleFlaeche() << "\n";
cout << "Der Flaecheninhalt der mittleren Box ist " <<
Mittel.HoleFlaeche() << "\n";
cout << "Der Flaecheninhalt der grossen Box ist " <<
Grosz.HoleFlaeche() << "\n";
return 0;
}
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Jan 02 2005
|