Hi everyone, I'm fairly new to c++ programming and I was just experimenting with this program, that works out symbol frequency, and I was wondering how I would turn this .cpp file, into a .cpp file and a .h file.
Well if you would like all your work in the .h file, make a function there and put your work in there.
There you can include that file in your .cpp file and call that function.
It's also good practice if you define preprocessor directives, what this does is that if the code is already defined, then do not redefine it. This is separate to the actual program.
test.h file:
1 2 3 4 5 6 7 8 9 10 11 12 13
#ifndef test_h //check not already defined
#define test_h //if not, define
#include <string>
std::string foo()
{
std::string s = "Hello";
s += " World!";
return s;
}
#endif // test_h