我在Ubuntu 11.04上使用Netbeans 7.1.
以下电话
set< Triangle > V;
Run Code Online (Sandbox Code Playgroud)
给出错误消息
error: ‘set’ was not declared in this scope
Run Code Online (Sandbox Code Playgroud)
以及以下电话
vector< Triangle > ans;
Run Code Online (Sandbox Code Playgroud)
给出错误消息
error: ‘vector’ was not declared in this scope
Run Code Online (Sandbox Code Playgroud)
尽管我有这个
#include <vector>
#include <set>
#include <map>
Run Code Online (Sandbox Code Playgroud)
在C++文件的开头.
在帮助解决这一点将不胜感激.
彼得.
template<class T>
class Stack
{
public:
Stack()
{
cout<<"Enter size\n";
cin>>size;
//stackPtr=new int[size];
stackPtr= new T[size];
top =0;
}
~Stack()
{
delete[] stackPtr;
}
void display()
{
cout<<"*****************************\n";
for(int i=0;i<top;i++)
cout<<stackPtr[i]<<endl;
cout<<"*****************************\n";
}
bool Push()
{
int a;
cout<<"Enter element\n";
cin>>a;
if(isFull()==false)
{
stackPtr[top++]=a;
return true;
}
else
return false;
}
bool Pop()
{
if(isEmpty()==false)
{
top--;
return true;
}
else
return false;
}
bool isEmpty()
{
if(top==0)
return true;
else
return false;
}
bool isFull()
{
if(top==size)
return true; …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置帧缓冲区对象,但我收到错误.glGenFramebuffers总是未声明的,像glBindFramebuffer这样的其他类似的事情也是如此.
我认为问题与导入有关,但我不确定如何解决这个问题.glew有可能无法正确设置,但我还没有找到如何完全设置它的简单解释.
这是失败的代码.
myBuffer = 0;
glGenFramebuffers(1, &myBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, myBuffer);
glGenTextures(1, &renderedTexture);
// Bind to new texture
glBindTexture(GL_TEXTURE_2D, renderedTexture);
// Blank image
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, 1024, 768, 0,GL_RGB, GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glGenRenderbuffers(1, &dBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, dBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, 1024, 768);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, dBuffer);
// Set "renderedTexture" as colour attachement #0
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, renderedTexture, 0);
DrawBuffers[2] = {GL_COLOR_ATTACHMENT0};
glDrawBuffers(1, DrawBuffers); // "1" is the size of DrawBuffers
// Check framebuffer is ok
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
return false; …Run Code Online (Sandbox Code Playgroud) 我要做的就是从另一个函数调用一个简单的函数,为什么每次在convert_to_Roman函数中调用addRomanDigit时都会出错?程序不完整我只是想完成第一个功能.
//
// RomanCalculator.cpp
// HelloWorld
//
// Created by Feroze on 6/13/13.
// Copyright (c) 2013 Feroze Shahpurwala. All rights reserved.
//
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
string convert_to_Roman(int value)
{
string retVal;
/* if (value < 0)
{
retVal ="-";
value = -value;
} */
retVal = addRomanDigit(retVal, value/1000, 'M'); // ERROR HERE and for one below 'Use of undeclared identifier 'addRomanDigit'
value = value % 1000;
retVal = addRomanDigit(retVal, value/500, 'D'); …Run Code Online (Sandbox Code Playgroud) 我只是在学习C语言
我写了以下内容:
void main(void)
{
unsigned int curr_dat = 0; // The current dat file to use
unsigned char ch = 0; // Key entered at keyboard
unsigned char lastkey = 0; // Last key entered (movement command)
FILE *fp;
}
Run Code Online (Sandbox Code Playgroud)
但是,我在尝试编译时遇到这些错误:
error C2065: 'FILE' : undeclared identifier
error C2065: 'fp' : undeclared identifier
warning C4552: '*' : operator has no effect; expected operator with side-effect
我不确定为什么我相信FILE是C中的有效标识符
我正在使用VS2012的Developer Command Prompt进行编译
我正在构建一个iPhone应用程序并尝试使用Core Text Framesetter创建一个savePDFFile方法.
但是,我收到以下行的未声明标识符CTFramesetterRef错误 -
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);
Run Code Online (Sandbox Code Playgroud)
我试图调查此错误,虽然我的项目包括CoreGraphics框架,但似乎我仍然需要添加ApplicationServices框架.问题是我找不到我的Mac上的ApplicationServices框架/库(我试图"添加其他"框架但是找不到它).
有没有办法添加或下载它,如果它没有安装在我的电脑上?
非常感谢,
Dudi Shani-Gabay
我对我正在尝试编译的一些代码感到困惑.编译器给了我几十个"未声明的标识符"错误.它们似乎都是本地循环变量,如下所示:
for ( i = 0; i < 100; i++ )
Run Code Online (Sandbox Code Playgroud)
我可以很容易地解决它,但我不明白该代码如何为其他人编译.这些文件已经很久没有被触及过了.
VC++是否有某种编译器标志会自动假定int未声明的变量?我找不到它.是什么赋予了?
复制问题的最小完整代码示例:
for ( int i = 0; i < 100; i++ );
for ( i = 0; i < 100; i++ );
Run Code Online (Sandbox Code Playgroud) 我正在尝试在C中实现一个链表,我很难搞清楚为什么我在编译时遇到以下错误:
entryList.c:7:11: error: 'tmp' undeclared (first use in this function)
entry * tmp = NULL;
entryList.c:7:11: note: each undeclared identifier is reported only once for
each function it appears in
^
Run Code Online (Sandbox Code Playgroud)
我已经为这个程序写了一些链表,它们都使用了类似的语法,但编译器只抱怨这个.
我在header.h中有我的结构定义:
/*definition of entry type*/
typedef struct entry
{
char * label;
short int address;
struct entry * next;
} entry;
Run Code Online (Sandbox Code Playgroud)
在entryList.c中,我正在编写一个函数来将一个节点添加到链表中.
#include "header.h"
static entry * head = NULL;
void addEntry(char * entry, int line)
{
entry * tmp = NULL;
char * label = NULL;
tmp …Run Code Online (Sandbox Code Playgroud) 调试器告诉我我没有使用我的变量,但它也没有声明。这里发生了什么?if 语句有自己的作用域吗?不知何故,固定长度的数组似乎不在 if 块内的同一范围内。
我的最小例子
#include <stdio.h>
#include <stdlib.h>
void nullarray(int start,int end, char array[]){
if(start<end) // TODO used to be <=
{
array[start]='0';
nullarray(++start,end,array);
}else{array[start]='\0';}
}
int main()
{
int commaindex2=-1;
int mostdecimaldigits=6;
if(commaindex2==-1){
char decimalnum2[1];decimalnum2[0]='0';
}
else{
char decimalnum2[mostdecimaldigits]; // get enought store incl filling up zeros
nullarray(0,mostdecimaldigits,decimalnum2); // write zeros to array
}
printf("%s", decimalnum2);
}
Run Code Online (Sandbox Code Playgroud)
调试器输出
||=== Build: Debug in test4 (compiler: GNU GCC Compiler) ===|
D:\main.c||In function 'main':|
D:\main.c|20|warning: variable 'decimalnum2' set but not used …Run Code Online (Sandbox Code Playgroud) template<typename T>
T f() {
if constexpr (std::is_same<T, int>::value) {
T t = 10;
}else {
T t;
}
return t;
}
Run Code Online (Sandbox Code Playgroud)
我对上述代码的理解f是
int t = 10;
return t;
Run Code Online (Sandbox Code Playgroud)
或者
T t = // some default value for T
return t;
Run Code Online (Sandbox Code Playgroud)
取决于T. 在两者中都会有一个名为 的标识符t。为什么编译器仍然抱怨use of undeclared identifier 't'?。
编译器在解析constexpr语句之前是否检查未声明的标识符?
c++ ×5
c ×3
constexpr ×1
fbo ×1
framebuffer ×1
if-statement ×1
ios ×1
ios4 ×1
linked-list ×1
opengl ×1
scoping ×1
set ×1
templates ×1
vector ×1
visual-c++ ×1
xcode ×1