This is what my header file looks like exactly line for line
This is how my header is included in my main.cpp
#include "header.h" // this file links any other .cpp files
you don't have the define the class and its methods in the header file .You can declare them in the
header file and provide the definitions in the source file.
What do you mean? I have all my code in the c plus plus file, and I have that file "#include" 'd inside the header file, which is then linked into the main.cpp file.
This is my second day coding in c++, so I'm still familiarizing myself with the differences between "definitions" and "declarations" of classes.
Declaring a class is merely writing "class className {} " and defining them is making a prototype? I'm not sure.
Any ways. I was having no problems, everything is linked in. BUT I am not getting a drop down list of completions for methods, functions, and classes from other files that are linked to the main.cpp .
Don't include ".cpp" files from other files unless you know what you are doing.
I have no idea what you are talking about. Why wouldn't I make ".cpp" files if I need that to make c plus plus files. All I'm doing is "#include " plus the file name with it's extension into the header only, and it links.
Thanks for the link! I think I'm linking multiple sources together correctly now.
Here's my header :
#ifndef header_h
#define header_h
class math{
public:
int add( int, int);
int subtract( int, int);
};
#endif // math
and here's the corresponding .cpp file
#include "header.h"
int math::add( int x, int y){
return (x + y);
};
int math::subtract( int x, int y){
return( x - y );
};
Then lastly, how I link it into the main.cpp file
I'm sure this is much better then what I was previously doing, and it works exactly the same. But sadly, I'm still not seeing any drop down lists for completion in the Code::Blocks ide. I am doing something wrong? Or is there an option that can fix this?