草庐IT

boolean_scope

全部标签

c++ - 谷歌测试 Gtest.cc :812: error: 'gettimeofday' was not declared in this scope

我正在尝试通过命令行通过MinGW编译Google测试,但是当我尝试使用命令进行编译时gcc-ID:\gtest-ID:\gtest\include-ID:\gtest\include\gtestsrc\gtest_main.ccsrc\gtest-all.cc它抛出错误Gtest.cc:812:错误:'gettimeofday'未在此范围内声明我通过VisualStudio成功编译,所以我猜这不是代码的错误。还有其他人遇到过这个问题并且知道解决方案吗? 最佳答案 and是两个不同的包含

c++ - 错误 : 'object' was not declared in this scope

我是C++的新手,正在尝试制作大富翁游戏。不幸的是,它仍然显示两个类之间的声明错误。我已经尝试了所有方法,但真的不知道问题出在哪里。错误:“玩家”未在此范围内声明。引擎.h#ifndefENGINE_H#defineENGINE_H#include"Player.h"#includeusingnamespacestd;classEngine{public:Engine();//methodthatstartswithgame,takerandomnumberforgettingnumberofplayers,setplayerstovectorvoidplay();//methodwh

c++ - 当非限定名称查找涉及 using-directives 时 [basic.scope.hiding]p2 的解释

在c++中有两种隐藏的名字:1)普通名称隐藏:[basic.scope.hiding]p1(http://eel.is/c++draft/basic.scope.hiding#1):Anamecanbehiddenbyanexplicitdeclarationofthatsamenameinanesteddeclarativeregionorderivedclass([class.member.lookup]).2)隐藏在[basic.scope.hiding]p2(http://eel.is/c++draft/basic.scope.hiding#2)中的特殊名称类型:Aclassn

c++ - 在 boost::python 中公开 boost::scoped_ptr

我收到一个编译错误,说scoped_ptr的复制构造函数是私有(private)的,代码片段如下:classa{};structs{boost::scoped_ptrp;};BOOST_PYTHON_MODULE(module){class_("s");}虽然这个例子适用于shared_ptr。如果有人知道答案,那就太好了。谢谢 最佳答案 boost::scoped_ptr的语义禁止复制,而shared_ptr旨在被复制。您得到的错误是编译器告诉您某些代码(宏扩展?)正在尝试复制scoped_ptr但库不允许进行复制。

c++ - "gets() was not declared in this scope"错误

这个问题在这里已经有了答案:whyg++shows"gets()"notdeclared,evenafterincluding(3个答案)关闭2年前。使用以下代码,我得到“gets()未在此范围内声明”错误:#include#includeusingnamespacestd;intmain(){//stringstr[]={"Iamaboy"};stringstr[20];`gets(str);cout

c++ - 在顶层使用 shared_ptr 而不是 scoped_ptr 有什么优势吗?

我的团队对于指针容器在特定上下文中的使用存在一些分歧。请考虑:intmain(){//Toplevel.Thisisanimportantfacttothecontext//i.e.thatthefollowinginstanceisatthislevel//sothatitsmembersareessentiallyatprogramscope.MainClassmainClass;mainClass.run();}//AinstanceofaclassderivedfromBufferdoessomethingverycomplex//(ithasvarioushandlestor

c++ - 在 set<int> 与 vector<bool> 与 vector<boolean_t> 之间进行选择以用作位图(位集/位数组)

给定一系列索引(标识符),我想将每个索引映射到一个bool值,即://interfacepseudocodeinterfacebitmap{boolidentifier_is_set(unsignedintid_idx)const;voidset_identifier(unsignedintid_idx,boolval)const;};这样我就可以设置和查询每个ID(索引)是否已设置,您更喜欢用什么来实现它?我认为这叫做位数组或位图或位集,如果我错了请纠正我。假设最大标识符是预先确定的并且不大于1e6(1m),可能更小(10k-100k)。(这意味着sizeof(int)*maximu

c++ - GNU 编译器 vs. Visual Studio 在数组上分配 w/Length Constant w/in a Scope

我知道如果你在c/c++中设置一个动态值,你不能在括号内使用该值来分配一个数组(这会使它成为所谓的可变长度数组(VLA),其中currentC++standard不支持)...即见:C++:VariableLengthArrayhttp://en.wikipedia.org/wiki/Variable-length_array我不太明白(而且我在这里没有看到确切地问到的)是为什么GNUc/c++编译器(gcc、g++)没问题使用基于整数值的动态分配(据我所知),只要该值是数组分配范围内的常量,但VisualStudio不支持这一点并且将拒绝编译代码,吐出错误。例如在g++中voidFo

c++ - 依赖整数 boolean 转换的枚举

在我的编译器项目中,我有一个像这样的枚举enumResult{No,Maybe,Yes};我已将No明确地放在第一个位置,这样我就可以依赖false的boolean值评估。如果我的编译器不确定某事,并且必须等到运行时才知道事实,它的分析函数将返回Maybe。像这样使用if(!typesEqual(t1,t2)){diagnose(types_unequal)我想知道您或您的公司是否认为不与No明确比较是不好的作风if(typesEqual(t1,t2)==No){/*...*/}明确比较对我来说似乎很罗嗦,但依赖隐式boolean转换不知何故让我感到内疚。您以前有过这种感觉吗?您是如何

c++ - boost::scoped_lock 不适用于局部静态变量?

我制作了以下示例程序来使用boost线程:#pragmaonce#include"boost\thread\mutex.hpp"#includeclassThreadWorker{public:ThreadWorker(){}virtual~ThreadWorker(){}staticvoidFirstCount(intthreadId){boost::mutex::scoped_lock(mutex_);staticinti=0;for(i=1;i主类://ThreadTest.cpp#include"stdafx.h"#include"boost\thread\thread.hpp