草庐IT

TYPE_SYSTEM_ALERT

全部标签

c++ - 错误 : no type named 'vector' in namespace 'std'

为什么会这样?error:notypenamed'vector'innamespace'std';didyoumean'hecto'?voidaskForVector(std::vector*vector);#include#includevoidaskForVector(std::vector*vector);intmain(){std::vectorvector;intsize;askForVector(&vector);std::cout>size;vector->resize(size);for(inti=0;i>vector[i];}for(intj:*vector)std:

c++ - <type_traits> 的 is_function_pointer<>

中有这些:is_pointeris_functionis_member_function_pointer但不是这个:is_function_pointer为什么会这样? 最佳答案 [meta.unary.cat]中的特征旨在将每种类型归为一个类别。是void、integral、pointer等等。在这个层面上,pointer-to-function和pointer-to-int没有区别。并注意指向成员的指针不是指针。只不过是英文的谐音而已。它的目的是每个类型都返回true到[meta.unary.cat]中的一个特征。在这种分类中,

c++ - "Template argument for template template parameter must be a class template or type alias template"

templatestructList{};templateclass>structListHelper;templatestructListHelper>{};^/*Error:Templateargumentfortemplatetemplateparametermustbeaclasstemplateortypealiastemplate*/怎么了?我正在使用clang++SVN。 最佳答案 您有一个模板模板参数。您必须传递一个模板作为其参数。您改为将模板实例化作为其参数传递-这是一个具体类,而不是模板(其所有参数均已绑定(bi

c++ - 编译器错误 C4430 : missing type specifier - int assumed

这个问题在这里已经有了答案:Resolvebuilderrorsduetocirculardependencyamongstclasses(12个答案)关闭8年前。我有这个错误:“错误C4430:缺少类型说明符-假定为int。注意:C++不支持default-int”使用此代码示例://A.h#include"B.h"classA{B*b;..};//B.h#include"A.h"classB{A*a;//errorerrorC4430:missingtypespecifier-intassumed.};

c++ - 如何使用 type_info 进行类型转换?

我存储了一个指向type_info对象的指针。intMyVariable=123;conststd::type_info*Datatype=&typeid(MyVariable);我如何使用它来将另一个变量类型转换为该类型?我试过这个,但它不起作用:std::cout使用类型转换的函数形式也不起作用:std::cout 最佳答案 很简单,您不能使用type_info来做到这一点。此外,在您的示例中,DataType不是类型,它是指向type_info类型对象的指针。你不能用它来转换。转换需要类型,而不是指针或对象!在C++0x中,您

C++ 错误 : object of abstract class type is not allowed: pure virtual function has no overrider

继承有问题。我不知道我做错了什么。FigureGeometry.h#ifndefFIGUREGEOMETRY#defineFIGUREGEOMETRYstaticconstfloatPI=3.14159f;classFigureGeometry{public:virtualfloatgetArea()const=0;virtualfloatgetPerimeter()const=0;};#endifCircle.h#ifndefCIRCLE#defineCIRCLE#include"FigureGeometry.h"classCircle:publicFigureGeometry{fl

c++ - "boost::mpl::identity<T>::type"在这里有什么意义?

我正在检查clamp的执行情况在boost中:templateTconst&clamp(Tconst&val,typenameboost::mpl::identity::typeconst&lo,typenameboost::mpl::identity::typeconst&hi,Predp){//assert(!p(hi,lo));//Can'tassertp(lo,hi)b/ctheymightbeequalreturnp(val,lo)?lo:p(hi,val)?hi:val;}如果我查找文档,identity返回模板参数不变。Theidentitymetafunction.Re

全网最全c++中的system详解

这篇文章是二发,做了些微调,感兴趣的朋友可以看原文:C++中的system_一只32汪的博客-CSDN博客1,简介    system()函数是在C++制作中十分常用,有用的一个函数。        其效果类似于系统中"cmd"控制台和"bat"文件。    通常会在C++字符游戏,和C++整蛊程序中使用。    其形式是以:system("***");呈现。2,程序中的用法:    1,system("pause");        PAUSE能够暂停文件处理,并显示消息        如下↓#includeusingnamespacestd;intmain(){cout          

c++ - decltype(new any_type()) 是否可能发生内存泄漏?

我正在使用valgrind检查类指针的任何内存泄漏可能性,并发现以下程序没有内存泄漏:#include#include#includeusingnamespacestd;classbase{};intmain(){unique_ptrb1=make_unique();base*b2=newbase();cout::value::value这怎么可能? 最佳答案 decltype(还有sizeof)的操作数不会被求值,所以任何副作用,包括内存分配,都不会发生。只有类型是在编译时确定的。所以这里唯一的内存分配是在make_unique和

c++ - boost::system::(...)_category 已定义但未使用

我目前收到的编译器警告类似于我在问题标题中给出的警告。警告如....警告:“boost::system::generic_category”已定义但未使用警告:“boost::system::posix_category”已定义但未使用警告:“boost::system::errno_ecat”已定义但未使用警告:“boost::system::native_ecat”已定义但未使用据我所知,该程序没有受到任何影响。但是,我不喜欢到处都是警告,但我不知道这些警告试图告诉我什么,除了一些定义的和与boost相关的东西在某个地方没有被使用。但是,我定义的所有内容都已使用。我使用的boost