我正在 Visual Studio 2013 Preview 中制作一个项目,其中包括我正在学习 C++ 的教程中的代码。项目中的主文件包含一个程序,该程序能够启动同一项目中另一个 .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 文件但位于同一个项目中的函数的帮助。
谢谢