If your whole class, including all your class' function declarations looks like this:
class A {
int n;
public:
A::A(int num);
void disp_num();
};
A::A(int num) {
n = num;
}
void disp_num() {
std::cout << "n = " << n << std::endl;
}
Then you'll have to put the following in the header file:
class A {
int n;
public:
A::A(int num);
void disp_num();
};
Edit:: As you classes are spread amongst multiple files, don't forget to compile them all together :)
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
Tux, you should also tell him to place the conditional compilation preprocesor directive so that his files are not included more than once:
#ifdef MYHEADER_H
#define MYHEADER_H
//content of the files
#endif
This will make sure that this header file will be included only once even if you issue two #include directive.
siddhant3s
Practically a Posting Shark
816 posts since Oct 2007
Reputation Points: 1,486
Solved Threads: 140
#ifdef MYHEADER_H
#define MYHEADER_H
//content of the files
#endif
Shouldn't that be #if<strong>n</strong>def MYHEADER_H ?
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
Shouldn't that be #ifndef MYHEADER_H ?
Yes it should be.
siddhant3s
Practically a Posting Shark
816 posts since Oct 2007
Reputation Points: 1,486
Solved Threads: 140
>I cant write it like #include <Classes.h> , it wont let me to do
That's because Classes.h isn't in your compiler's header files directory, in that case you'll have to put quotes around it instead of < , if you use quotes like this: #include "Classes.h" , you tell your compiler that Classes.h is in the same directory as your other source files :)
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243