【发布时间】:2015-05-25 21:19:51
【问题描述】:
我刚开始使用 Visual Studio 2013。直到我开始将 #include "stdafx.h" 放在每个 cpp 文件的开头,我的代码才会编译。当其他人通过Linux终端编译我的代码时,这会导致任何问题吗?如果我只是从以下代码中删除#include "stdafx.h",它会用 g++ 编译 C++11 吗?
#include "stdafx.h"
#include<iostream>
using std::cout; using std::endl; using std::cin;
using namespace std;
int main()
{
cout << "This is an awesome game to play with your friends!"
<< endl << "You have to pick an integer between 10 and 49 and type it in"
<< endl << "Then your friend has to pick an integer between 50 and 99 and type it in."
<< endl << "Through a series of highly advanced calculations starting with their number,"
<< endl << "They regenerate your original number. Have fun!"
<< endl << ""
<< endl << "Please enter your integer number, between 10 and 49:";
int your_int, their_int, factor, sum, calculation, result;
cin >> your_int;
factor = 99 - your_int;
cout << "Factor: " << factor
<< endl << "Now, please enter your friend's integer number between 50 and 99:";
cin >> their_int;
sum = factor + their_int;
calculation = sum / 100 + sum % 100;
result = their_int - calculation;
cout << "The sum is: " << sum
<< endl << "The calculation is : " << calculation
<< endl << "The result is :" << result
<< endl << "My answer was: " << your_int
<< endl << "Your result was: " << result;
return 0;
}
【问题讨论】:
-
这完全取决于
stdafx.h的内容。当你尝试它时会发生什么?添加包含之前的错误消息是什么? -
我的导师使用 Linux 使用 g++ 进行编译。我的 PC 上的 Linux 一直存在问题。所以我一直在使用 Visual Studio 2013。我
标签: c++ visual-studio c++11