小编Nik*_*lis的帖子

"to_string"不是"std"的成员?

好的,我有

tmp.cpp:

#include <string>

int main()
{
    std::to_string(0);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试编译时,我得到:

$ g++ tmp.cpp -o tmp
tmp.cpp: In function ‘int main()’:
tmp.cpp:5:5: error: ‘to_string’ is not a member of ‘std’
     std::to_string(0);
     ^
Run Code Online (Sandbox Code Playgroud)

我正在运行g ++版本4.8.1.与我在那里发现的所有其他对此错误的引用不同,我没有使用MinGW,我在Linux(3.11.2)上.

任何想法为什么会这样?这是标准的行为,我做错了什么或某处有错误?

c++ linux string g++ c++11

40
推荐指数
2
解决办法
8万
查看次数

用于远程获取硬盘和处理器规范的命令

什么是命令有助于获取远程Windows机器中的硬盘和处理器的信息?

windows cmd wmic

11
推荐指数
1
解决办法
7万
查看次数

这里不允许声明C中的错误

以下行有问题int (*f)(int, int) = (argv[2][0] == 'd'),编译时声明此处不允许声明.如果该行在开始时被声明,那么任何更好的方法都可以做到这一点.任何建议都会受到高度赞赏吗?

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int encode(int ch, int key) { 
        if (islower(ch)) {
                ch = (ch-'a' + key) % 26 + 'a';
                ch += (ch < 'a') ? 26 : 0;
        }
        else if (isupper(ch)) {
                ch = (ch-'A' + key) % 26 + 'A';
                ch += (ch < 'A') ? 26 : 0;
        }
        return ch;
}

int decode(int ch, int key) { 
        return encode(ch, -key);
}

int …
Run Code Online (Sandbox Code Playgroud)

c

4
推荐指数
1
解决办法
2万
查看次数

这个递归代码有什么问题?

我正在使用CodeLab for C++进行在线工作,我不确定我的代码有什么问题.这是一个问题:

编写一个递归的,值为int的函数len,它接受一个字符串并返回字符串中的字符数.如果字符串是空字符串(""),则字符串的长度为:0.比第一个字符之外的其余字符串的长度多1个.

这是我的代码:

int len(string s)
{
  if (s.length()==0)
    return 0;
 else
 {
    return 1+(len(s)-1);
 }
}
Run Code Online (Sandbox Code Playgroud)

它说我有一个运行时错误.有帮助吗?

谢谢.

c++ stack-overflow recursion

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

什么是代码块,显然没有在.c文件上做什么?

这段代码意味着什么?具体来说,花括号在做什么?它们不在功能中.

yyerror(s) char * s;

{
    fputs(s,stderr), putc('\n',stderr);
}
Run Code Online (Sandbox Code Playgroud)

c

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

我的双打发生了什么事?

所以,我正在写一个光线跟踪器,我有一个基本类来表示视口.它看起来像这样:

camera.hpp:

#define real double

class Camera
{
    // self explanatory
    Vector3 origin, destination, up;

    // camera's coordinate system
    // N    = normal to projection plane ("z-axis")
    // U, V = x- and y-axes of projection plane
    Vector3 N, U, V;

    // Directional increment vectors for screen-space X and Y
    Vector3 xInc, yInc;

    // vFOV derived from hFOV
    real    horizontalFOV, verticalFOV;

    // width and height of projection buffer in pixels
    real    width, height;

public:
    // Constructs a camera
    // pO …
Run Code Online (Sandbox Code Playgroud)

c c++

-2
推荐指数
1
解决办法
192
查看次数

标签 统计

c ×3

c++ ×3

c++11 ×1

cmd ×1

g++ ×1

linux ×1

recursion ×1

stack-overflow ×1

string ×1

windows ×1

wmic ×1