小编use*_*546的帖子

编译需要#include "stdafx.h"

我刚开始使用 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 …
Run Code Online (Sandbox Code Playgroud)

c++ visual-studio c++11

1
推荐指数
1
解决办法
4527
查看次数

具有常量引用的函数作为输入

我正在尝试创建一个函数,该函数将字符串的常量引用作为输入,并在字符串的每个字符向右旋转1个位置后返回字符串.使用引用和指针仍然让我困惑,我不知道如何从常量引用中获取字符串.

string rotate(const string &str){
     string *uno =  &str;
     string dos = rotate(uno.rbegin(), uno.rbegin() + 1, uno.rend());
     return dos;}
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止所得到的,但它没有编译.任何有关如何从常量引用中正确获取字符串的提示将不胜感激.

c++ string reference

0
推荐指数
1
解决办法
58
查看次数

标签 统计

c++ ×2

c++11 ×1

reference ×1

string ×1

visual-studio ×1