草庐IT

int_types

全部标签

c++ - 通过在 Fortran 中调用 C++ 函数将 Fortran int 数组传递给 C++

我正在尝试在Fortran子例程中调用C++函数。这个C++函数应该更新一个整数数组。这是我写的一个非工作代码。什么问题?!FortranfunctionthatcallsaC++function.subroutinemy_function()integer(4)ar(*)integer(4)get_filled_ar!Needcorrectsyntaxhere.ar=get_filled_ar()end//C++function:extern"C"{voidget_filled_ar(int*ar){ar[0]=1;ar[1]=10;ar[3]=100;}}

c++ - 转发声明/包含在模板类中 - "invalid use of incomplete type"

我正在尝试制作一个模板类,其中有一个函数接受该模板的特定实例。我做了以下人为的例子来说明这一点。比方说,我有一个标有模板化(通用)数据类型的个人世界。我有一个特定的个体,称为国王。所有个人都应该能够在国王面前下跪。一般来说,个人可以被标记为任何东西。国王用数字标记(第1、2位国王)。错误g++-g-O2-Wall-Wno-sign-compare-Iinclude-DHAVE_CONFIG_H-c-oIndividual.oIndividual.cppg++-g-O2-Wall-Wno-sign-compare-Iinclude-DHAVE_CONFIG_H-c-oKing.oKing

c++ - "member of type foo has private copy constructor"错误 : why's it an error?

我试图定义这样一个类:#includeclassmy_class{private:someone_elsesfoo;public:myclass();~myclass();//...};但是编译器失败了:“someone_elses类型的字段foo有一个私有(private)的复制构造函数”。现在我知道我可以通过以下方式解决这个问题:classmy_class{private:someone_elses*foo;//...};my_class::my_class(){foo=newsomeone_elses();}my_class::~my_class(){deletefoo;}我的问

c++ - 编译错误 : unresolved overloaded function type

我尝试用g++4.7.2编译以下内容:templatestructA{structB{Tt;templateTget(){returnthis->*M;}};Bb;Tget(){returnb.get();}};intmain(){Aa;a.get();}它给了我test.cpp:Inmemberfunction‘TA::get()’:test.cpp:15:23:error:expectedprimary-expressionbefore‘)’tokentest.cpp:Ininstantiationof‘TA::get()[withT=int]’:test.cpp:22:8:req

c++ - 错误 : aggregate 'first one' has incomplete type and cannot be defined

我写了这个头文件(header1.h):#ifndefHEADER1_H#defineHEADER1_Hclassfirst;//intsumm(inta,intb);#endif和这个源文件(header1.cpp和main.cpp):#include#include"header1.h"usingnamespacestd;classfirst{public:inta,b,c;intsum(inta,intb);};intfirst::sum(inta,intb){returna+b;}#include#include"header1.h"usingnamespacestd;firs

c++ - operator++()和operator++(int)有什么区别?

这个问题在这里已经有了答案:Overloading++forbothpreandpostincrement(4个答案)关闭9年前。我有我老师制作的程序中的这些行代码:TimeKeeper&operator++(){d_seconds++;return*this;}constTimeKeeperoperator++(int){TimeKeepertk(*this);++(*this);returntk;}我的老师问我们的问题之一是“operator++()返回一个引用而operator++(int)返回一个值,请解释为什么?”谁能给我解释一下??如果您需要其余的代码,我不介意把它放在上面

解决日期转换异常 JSON parse error: Cannot deserialize value of type `java.util.Date` from String总结

不积跬步,无以至千里;不积小流,无以成江海-----致奋斗的自己场景:前端向后端传日期参数,后端接收问题,在一次遇到这种低级问题总结一下。文档参考:​​​​​​​SpringFramework中文文档-SpringFramework4.3.21.RELEASEReference|Docs4devSpring是一个开放源代码的设计层面框架,它解决的是业务逻辑层和其他各层的松耦合问题,因此它将面向接口的编程思想贯穿整个系统应用。Spring是于2003年兴起的一个轻量级的Java开发框架,由RodJohnson创建。简单来说,Spring是一个分层的JavaSE/EEfull-stack(一站式)

c++ - 这是什么语法 : "ACGT"[(int)qrand() % 4]

我正在查看Qt特定的C++solution对于典型的生产者/消费者问题。这是生产者的代码:classProducer:publicQThread{public:voidrun(){qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));for(inti=0;i我无法理解for循环中的第二行,即。"ACGT"[*]语法。它具体做什么?这是Qt特定的还是我不知道的C++语法?PS:完整源代码here 最佳答案 它生成一个随机字符:A、C、G、T。Literal"ACGT"是charconst[

c++ - C++中的int(expr)是什么意思?

在查看friend项目中的一些代码时,我最近看到了类似这样的语法。#includeintmain(){std::cout当您运行上面的代码时,您会得到6,如果使用int功能(如强制转换),这是预期值。但是,我以前从未见过这种语法,也无法在网上找到它的文档。我还做了一个实验,发现这种语法在C中无效。谁能用文档引用解释这个语法的含义? 最佳答案 这不是构造函数调用或“函数”。没有“int函数”。这是函数式转换符号;it'sjustacast.它与(int)(32.5/5)相同(在这种特殊情况下)。而且,不,C没有它。

C++ 重载歧义 : conversion versus promotion with primitive types

在这段代码中:voidf(floatf,longinti){cout有一个歧义。Checkitout!.但是,第二个参数是有符号整数。将int绑定(bind)到longint参数需要提升,但对于float,则需要转换。由于第一个参数是关于两个重载的完全匹配,所以它不算数。但是关于第二个参数,它在第一次过载(提升)上的排名优于在第二个(转化)上的排名。为什么会出现解析歧义,而不是选择第一个重载? 最佳答案 int到long是一个转换。short到int是一种提升。(有关积分促销的完整列表,请参阅[conv.prom]。)同理,floa