C++ を学習しているチュートリアルのコードを含む Visual Studio 2013 Preview でプロジェクトを作成しています。プロジェクトのメイン ファイルには、同じプロジェクトの別の .cpp ファイルで定義された関数を起動できるプログラムが含まれています。そのコードは以下のとおりです。
#include "stdafx.h"
#include <iostream>
#include "Comments.cpp"
#include "Structure of a Program.cpp"
int structure(void);
void comment(void);
int main()
{
using namespace std;
cout << "This project contains files related to Chapter 1 of Learn CPP
Tutorials\n" << endl;
cout << "Please type in the tutorial number to view its output:\n" <<
"1 - Structure of a Program\n" <<
"2 - Comments\n" <<
"3 - A First Look at Variables (and cin)\n" <<
"4 - A First Look at Functions\n" <<
"5 - A First Look at Operators\n" <<
"6 - Whitespace & Basic Formatting\n" <<
"7 - Forward Declarations\n" <<
"8 - Programs With Multiple Files\n" <<
"9 - Header Files\n" <<
"10 - A First Look at the Preprocessor\n" <<
"11 - How to Design your First Programs\n" << endl;
int x;
cin >> x;
if (x == 1)
{
structure();
}
if (x == 2)
{
comment();
}
cout << "Thank you for using this program. Good bye." << endl;
return 0;
}
私が抱えている問題は、プログラムをビルドするときに、起動している関数が定義されていないにもかかわらず、既に定義されているというエラーが常に発生することです。基本的に、別の .cpp ファイルにあるが同じプロジェクトにある関数を起動する方法について助けが必要です。
ありがとう