【问题标题】:use of undeclared identifier make_tuple [duplicate]使用未声明的标识符 make_tuple [重复]
【发布时间】:2020-03-17 16:17:58
【问题描述】:

这是我程序的开始

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <vector>

#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

#define _USE_MATH_DEFINES
#include <math.h>

const int NR_TREES = 100;
const int R = 50;
const int RI = 35;
const int RC = 15;

using namespace std;

float oldX, oldY;
float cameraAlfa, cameraBeta;
float cameraX, cameraY, cameraZ;
float dirX, dirY, dirZ;

vector<tuple<float, float>> treePoints;


void populateTrees(){
    srand(clock());

    for(int i = 0; i < NR_TREES; i++){
        float x = (float) (rand()) / ((float) (RAND_MAX/200)) - 100;
        float y = (float) (rand()) / ((float) (RAND_MAX/200)) - 100;

        if(x * x + y * y > R * R){
        treePoints.push_back(make_tuple(x, y)); //problem here
        }
        else{
            i--;
        }
    }
}

但是,当我尝试编译时,它说“使用未声明的标识符 make_tuple”,即使在向量声明中认为它与元组完美配合。老实说,我不知道... 任何帮助将不胜感激。

【问题讨论】:

  • 投票结束是一个错字。你忘了包括&lt;tuple&gt;。您必须始终包含您使用的函数的标头。
  • 那行得通,但我认为 make tuple 来自 std?
  • 谢谢,不知道使用函数和类型的区别
  • @PedroFernandes 这与函数与类型有关。您总是必须为您正在使用的 everything fromstd:: 添加正确的标头。

标签: c++ tuples


【解决方案1】:

需要包含元组。很困惑,因为元组本身在 std

【讨论】:

  • 这个答案的推理没有意义,请参阅问题下的评论。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多