The above shows the error I am getting when I build main.cpp from Microsoft Visual Studio
main.cpp file
#include <iostream>
#include "catalan.h"
using namespace std;
int main()
{
int selection;
int number;
}
return 0;
}
This is the catalan.h file:
#include "implementation.cpp"
int catalan(int n);
int fibonacci(int x);
void menu();
This is the implementation.cpp file
int catalan(int n)
{
if (n <= 1)
return 1;
int result = 0;
return result;
}
int fibonacci(int x)
{
return 0;
}
void menu()
{
std::cout << "1. Do Catalan numbers" << std::endl;
}
Don't include .cpp
files like you do in #include "implementation.cpp"
. Include header files and compile .cpp
files.
When you've removed #include "implementation.cpp
you may be required to add missing #include
s to the .cpp
file if it currently relies on that you've done #include <iostream>
for example.
In g++
, it would mean compiling this this:
g++ main.cpp implementation.cpp -o program_name
In Visual Studio it would mean adding the missing .cpp
file to the project. It should be either main.cpp
or implementation.cpp
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.