C++locale.h
->Semantic Issue
-->Use of undeclared identifier 'va_start'
->Semantic Issue
-->Use of undeclared identifier 'va_end'
Run Code Online (Sandbox Code Playgroud)
首次使用boost,使用ports下载并在XCode中创建了一个命令行项目.标题搜索路径:/ usr/include/**
代码中没有任何内容,只是默认项目附带的主要功能.
只是不知道该怎么做,从未预料到会发生这种情况.
EDIT1:
第一次出现:
#ifndef _GLIBCXX_CSTDARG
#define _GLIBCXX_CSTDARG 1
#pragma GCC system_header
#include <bits/c++config.h>
#include <stdarg.h>
// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
#ifndef va_end
#define va_end(ap) va_end (ap)
#endif
_GLIBCXX_BEGIN_NAMESPACE(std)
using ::va_list;
_GLIBCXX_END_NAMESPACE
#endif
Run Code Online (Sandbox Code Playgroud)
它是\ usr\include\c ++\4.2.1中没有扩展名的文件,我刚刚意识到这个文件与boost无关,这里有一些令人讨厌的事情发生.
EDIT2:将include目录修复到/ opt/local/include/**后出现新错误:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/type_traits:214:46:
Use of undeclared identifier 'nullptr_t'; did you mean 'nullptr'?
Run Code Online (Sandbox Code Playgroud)
还有其他错误,都与文件夹sr/lib/c ++/v1中的这些文件有关/为什么?这些文件似乎是一些核心功能,它们无法破解.
这是错误的图片,也许你们看到的东西

编辑3:将编译器从Apple LLVM更改为GCC LLVM将错误减少到只有一个:"vspintf不是c ++ locale.h中'std'的成员".好的,现在我完全迷失了.
我有一个五次函数(五次多项式),我想用C++解决它.是否有可以使用的实现或数学库才能继续?
我在一页上有3个旋转木马,由一个控件控制.因此,当点击下一个或上一个所有轮播时,立即移动.
这个例子有3个旋转木马,但都是分开的.
我被卡住了.
我正在尝试使用OpenGL创建一个烟花(我必须在位置(0,0,0)中放置100个粒子)
Particle *p[100];
void Build()
{
for (int i = 1; i <= 100; i++)
{
p[i]->pos.x = 0.0;
p[i]->pos.y = 1.0;
p[i]->pos.z = 5.0;
p[i]=AddParticle(*p[i]);
}
}
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
ass.exe中0x771b15de处的未处理异常:0xC0000005:访问冲突写入位置0x00000000.
这是代码的其余部分:
class Particle
{
public:
Vector3 pos; // current position
Vector3 vel; // velocity
Vector3 restPos; // rest (initial) position
Vector3 oldPos; // previous position
Vector3 acc; // acceleration
Particle()
{
oldPos = restPos = pos = Vector3(0, 0, 0);
Init();
}
Particle(float x, float y, float z)
{
oldPos …Run Code Online (Sandbox Code Playgroud) 我见过很多类似的问题,但似乎没有一个问题适合我的代码,我想我忽略了一些基本的东西,也许你可以提供帮助.
现在我正构造一个字符串作为请求发送到winsock发送函数,这需要发送char [].我需要将我的std :: string转换为char数组(char []).
目前这是有效的请求:
char request [] = "GET /gwc/cgi-bin/fc?client=udayton0.1&hostfile=1HTTP/1.0\nHost:www.gofoxy.net\n\n";
Run Code Online (Sandbox Code Playgroud)
但我需要将一个请求的字符串更改为相同的数据结构.
我感谢任何帮助!
编辑:
我可以将字符串转换为char*,但是如何使用它来获取字符数组呢?我希望我不会让它更加混乱.以下是两次尝试在运行时生成与发送请求不兼容的char star:
//convert request into a char[]
//char *req_ch = new char[req_str.size()+1];
//hostCh[req_str.size()] = 0;
//memcpy(req_ch, req_str.c_str(), req_str.size());
//char * req = new char[req_str.size() +1];
//std::copy(req_str.begin(), req_str.end(), req);
//req[req_str.size()] = '\0';
Run Code Online (Sandbox Code Playgroud) 我只是想在排序或删除元素后询问迭代器是否有效.当我们插入容器时,可以重新分配它以查找更多空间并使现有迭代器无效.但是排序和删除元素会发生什么?那些人可以强制重新分配容器吗?
这段代码会崩溃一次吗?
QVector<Foo> container;
b = container.begin();
e = container.end();
while (container.count() > newCount)
{
computeSomePropertyOfFoo(b, e); // Computes property between b and e
sortByThatProperty(b, e); // sorts members between b and e
container.erase(--e);
}
Run Code Online (Sandbox Code Playgroud) 我无法重载比较运算符>和<.我尝试了两种不同的方式,但我仍然遇到麻烦.
bool Car::operator ==(const Car &car)
{
return mLNumber == car.GetNum();
}
bool Car::operator <(const Car &carB)
{
return mLNumber < carB.GetNum();
}
bool Car::operator >(const Car &carB)
{
return mLNumber > carB.GetNum();
}
int Car::GetNum()
{
return mLNumber;
}
Run Code Online (Sandbox Code Playgroud)
我的==操作员工作正常.我得到这些运算符不存在的错误.这是我的第二次尝试.
bool Car::operator <(const Car &carA, const Car &carB)
{
return carA.GetNum() < carB.GetNum();
}
bool Car::operator >(const Car &carB)
{
return carA.GetNum() > carB.GetNum();
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是参数太多了.我也明白了:
'Car::GetNum' : cannot convert 'this' pointer from …Run Code Online (Sandbox Code Playgroud) 我用OpenGL创建2D游戏.每次我移动我的对象时,我都要调用glLoadIdentity,因为否则所有对象都会移动,但glLoadIdentity也会重置glOrtho调用,所以基本上我以这样的结尾:
#include <GL/glfw.h>
int main()
{
glfwInit();
glfwOpenWindowHint( GLFW_WINDOW_NO_RESIZE, GL_TRUE );
glfwOpenWindowHint( GLFW_FSAA_SAMPLES, 8 );
glfwOpenWindow( 800, 600, 0, 0, 255, 0, 32, 0, GLFW_WINDOW );
glfwSetWindowTitle( "title" );
glfwSwapInterval( 1 ); // also known as 'vsync'
glfwEnable( GLFW_KEY_REPEAT );
//glfwDisable( GLFW_MOUSE_CURSOR );
glOrtho(0.0, 1024, 768, 0, -1.0, 1.0);
glMatrixMode( GL_MODELVIEW );
while( !glfwGetKey( GLFW_KEY_ESC ) )
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glOrtho(0.0, 1024, 768, 0, -1.0, 1.0);
glTranslatef( 100, 0, 0 …Run Code Online (Sandbox Code Playgroud) 我有一个std ::对象的映射,其实例构造起来非常昂贵.(在现实生活中,他们需要多次访问数据库.)
我想访问地图的一个元素,或者如果它不存在则创建它.这听起来像std :: map :: insert的工作,除了昂贵的对象不必要地构造,然后如果元素存在则抛弃.为了显示:
#include <iostream>
#include <map>
#include <string>
struct CexpensiveObject
{
CexpensiveObject(const char* args="default"):args_(args)
{
std::cout << "Constructor: CexpensiveObject(" << args << ")" << std::endl;
}
CexpensiveObject( const CexpensiveObject& other )
{
std::cout << "Copy Constructor: CexpensiveObject other.args_ = " << other.args_ << "." << std::endl;
args_ = other.args_;
}
~CexpensiveObject()
{
std::cout << "Destructor: CexpensiveObject args_ = " << args_ << "." << std::endl;
}
const char* args_;
};
// entry point
int main() …Run Code Online (Sandbox Code Playgroud) 我创建了一个结构:
struct time
{
int hours;
int minutes;
int seconds;
double total_time;
double price;
time* next;
time* back;
};
Run Code Online (Sandbox Code Playgroud)
我已经创建了2个指向结构的指针:
time* traverse, head;
Run Code Online (Sandbox Code Playgroud)
我想将头部的位置指向与头部相同的位置:
traverse = new time;
head = traverse; // Error here
Run Code Online (Sandbox Code Playgroud)
为什么我在作业中收到错误?
C++程序是这样的:
class Foo
{
// something here
};
int main ()
{
Foo f_A;
Foo f_B;
Foo f_C;
//do something here
return 0;
}
Run Code Online (Sandbox Code Playgroud)
事实已经证明,f_A之前的构造f_B,解构之后f_B,以及在g ++ 之后f_B解构f_C.确定序列的是什么?编译器是否相关?