So I have a main.cpp file with a simple hello world program containing a function that prints hello world, and a main method. How do I move only the function that prints hello world into a different .cpp file. I have a main.cpp, function.cpp and function.h files.
I've tried to #include function.h in the function.cpp file but won't work.
// main.cpp
#include <iostream>
std::string funct()
{
return "hello";
}
int main()
{
std::cout<<funct()<<std::endl;
return 0;
}
// function.h
string funct();
//function.cpp
?