次のような 3 つのファイルがあります。
Movie.h
struct Movie{
char title[30]; // the hour of the current time
char director[30]; // the minute of the current time
int length;
} ;
void printMovieInfo(Movie *s);
ムービー.cpp
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include "Movie.h"
using namespace std;
void printMovieInfo(Movie *s){
cout << "Hi";
}
およびメインのファイル
#include "Movie.cpp"
using namespace std;
int main()
{
struct Movie *m;
printMovieInfo(m);
}
プログラムを実行すると、次のエラーが表示されます。
collect2 ld returned 1 exit status
および警告:
/tmp/ccIe4dlt.o In function `printMovieInfo()':
Movie.cpp (.text+0x0): multiple definition of `printMovieInfo()'
/tmp/cc91xrNB.o HelloWorld.cpp:(.text+0x0): first defined here
関数を呼び出して「こんにちは」を出力したいだけですが、なぜこのエラーが発生するのかわかりません