草庐IT

a_very_long_method_name

全部标签

c++ - 关于long long和long double

它们什么时候成为标准C++的一部分?我认为longlong是C++0x的特性,对吗?longdouble怎么样?它已经在C++98或C++03中了吗? 最佳答案 longdouble和longlong已经存在了很长一段时间,并分别在C89和C99中标准化。C++从其第一个版本C++98标准化了longdouble,并将在即将到来的标准修订中添加longlong。 关于c++-关于longlong和longdouble,我们在StackOverflow上找到一个类似的问题:

c++ - 如何从 unsigned long 转换为 void*?

我正在尝试在具有给定文件描述符的文件的某个偏移处pwrite一些数据。我的数据存储在两个vector中。一个包含unsignedlong和其他char。我想构建一个void*指向代表我的unsignedlong和char的位序列,并将它传递给pwrite以及累积大小。但是如何将unsignedlong转换为void*?(我想我可以找出字符)。这是我正在尝试做的事情:voidwriteBlock(intfd,intblockSize,unsignedlongoffset){void*buf=malloc(blockSize);//hereIshouldbetryingtobuildbuf

c++ - c++11 中的 typeid(T).name() 替代方案?

在c++11中是否有一种标准的方法来使用一些模板黑魔法或动态地使用一些标准库函数来获取类的名称? 最佳答案 不,但你可以做一个:templatestructmeta{staticconststd::string&get_name(){returnT::class_name;}};然后将静态成员class_name添加到类中:classMyClass{public:staticconststd::stringclass_name("MyClass");};或专门化元:templatestructmeta{staticconststd:

c++ - 这是正确的 : virtual method of Derived called before constructing Base object?

我知道在Base类的构造函数中-当调用虚拟方法时-调用Base方法,而不是派生-参见Callingvirtualfunctionsinsideconstructors.我的问题与这个主题有关。我只是想知道如果我在Derived类构造函数中调用虚拟方法会发生什么-但在构造Base部分之前。我的意思是调用虚方法来评估基类构造函数参数,请参见代码:classBase{public:Base(constchar*name):name(name){cout编译器g++(4.3.x-4.5x版本)输出为:Derived::getName()Base():DerivedDerived():Deriv

c++ - "Expected class-name"...析构函数实现中的问题

我正在尝试实现堆栈和队列。我还获得了用于测试堆栈和队列的代码(以查看它们各自的功能是否正常工作)。我已经实现了stack和quete的功能,但是在尝试编译它们时出现错误:在析构函数“Stack::~Stack()”中'('标记前的预期类名在他们两个。以下是通用的Stack类:templateclassStack{Listlist;public:Stack();Stack(constStack&otherStack);~Stack();}列表类:templateclassList{ListItem*head;public:List();List(constList&otherList);

c++ - 错误 : expected primary-expression before ‘>’ : templated function that try to uses a template method of the class for which is templated

这个问题在这里已经有了答案:WhereandwhydoIhavetoputthe"template"and"typename"keywords?(8个答案)关闭8年前。在使用模板和仿函数(未出现在这个问题中)时,我最终遇到了以下简化的问题。以下代码(也可用here)classA{public:templateboolisGood(intin)const{constTf;returninbooltryEvaluator(T&evaluator,intvalue){returnevaluator.isGood(value);}intmain(intargc,constchar*argv[]

从[parendid,name]目录dict到完整的路径dict

我有一个目录的命令[parentid,name]像这样:D={0:[-1,'C:'],1:[0,'BLAH'],2:[0,'TEMP'],3:[1,'BOOO'],4:[1,'AZAZ'],5:[2,'ABCD']}我想从这途径到完整的道路:FULLPATHS={}forkey,pathinD.iteritems():newpath=path[1]ifpath[0]!=-1:newpath=FULLPATHS[path[0]]+'\\'+newpathFULLPATHS[key]=newpath有用:{0:'C:',1:'C:\\BLAH',2:'C:\\TEMP',3:'C:\\BLAH\\

vue3+vite+typescript出现does not provide an export named ‘xxx‘ 解决方法

vue3+vite+typescript出现doesnotprovideanexportnamed‘xxx’解决方法。在使用TinyMCE富文本组件时,出现以下错误:Therequestedmodule‘/src/main/ts/components/EditorPropTypes.ts?t=1674647216370’doesnotprovideanexportnamed‘IPropTypes’。对应EditorPropTypes.ts中的代码:exportinterfaceIPropTypes{apiKey:string;cloudChannel:string;id:string;init

c++ - 如何在 C++ 中提高 int 或 long 的幂

小问题:我只是想知道,如果一个人想要将一个int或long提高到另一个int或long的幂,会吗(long)std::pow((double)a,(double)b)够用还是需要(long)(0.5+std::pow((double)a,(double)b))? 最佳答案 有两个考虑因素。第一个是由于浮点表示的不精确而导致的舍入;在这种情况下这不是问题,因为只要位数少于float中的有效位数,整数就可以完美表示。如果long是32位并且doublesignificand是53位,通常情况下,不会有问题。第二个考虑因素是pow函数本身

C++:将 unsigned long long int 转换为 vector<char> ,反之亦然

谁能告诉我如何将unsignedlonglongint转换为vector,反之亦然。为了将unsignedlonglongint转换为vector,我尝试了以下操作:unsignedlonglongintx;vectorbuf(sizeof(x));memcpy(&buf[0],&x,sizeof(x));当我测试x=1234567890时,它失败了。但是当我尝试使用较小的x值(比如1-100)时,它起作用了……为了将vector转换为unsignedlonglongint,我使用了:unsignedlonglongint=(unsignedlonglongint)buf[0];谁能告