草庐IT

some_parameter

全部标签

php - 警告 : number_format() expects parameter 1 to be double

我收到Warning:number_format()expectsparameter1tobedoubleerror我的代码$tbl->addRow();$tbl->addCell($name);$tbl->addCell('$'.number_format(doubleval($price),2,',',''));我知道$price的值是15,00,这是一个数字。怎么修? 最佳答案 可能doubleval()返回某种错误,因为数字“15,00”是欧洲格式而不是标准格式。您是否尝试过使用“15.00”代替?

c++ - gcc not_fn 实现 : why does _Not_fn accept additional int parameter?

最近我看了看implementation的std::not_fngcc提供的函数模板。此函数模板的返回类型是_Not_fn-一个包装类模板,它否定包装的可调用对象。事实证明,_Not_fnconstructor接受一个未明确使用的附加int参数:template_Not_fn(_Fn2&&__fn,int):_M_fn(std::forward(__fn)){}对构造函数的调用如下所示:templateinlineautonot_fn(_Fn&&__fn)noexcept(std::is_nothrow_constructible,_Fn&&>::value){return_Not_f

c++ - 'CreateDirectoryW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR' in OpenCV 2. 4.5 和 VS 2010

我正在尝试从openCV2.4.5到VisualStudio2010(基于VC++)的示例代码bagofwords_classification.cpp。但是我发现了错误代码:errorC2664:'CreateDirectoryW':cannotconvertparameter1from'constchar*'to'LPCWSTR'你能帮我解决那个问题吗?谢谢。:)更新v1:staticvoidmakeDir(conststring&dir){#ifdefinedWIN32||defined_WIN32CreateDirectory(dir.c_str(),0);#elsemkdir

c++ - Visual Studio 2010 Arduino cpp 错误 : argument of type "char *" is incompatible with parameter of type "LPCWSTR"

我正在尝试设置一个arduinouno用于与visualstudio2010中的C++程序进行串行端口通信。我正在使用此处找到的代码:http://playground.arduino.cc/Interfacing/CPPWindows不幸的是,.cpp文件在第9行为变量“portName”提供了以下消息:错误:“char*”类型的参数与“LPCWSTR”类型的参数不兼容我不明白这个错误消息,并尝试了一些不同的方法来修复它。任何帮助将不胜感激! 最佳答案 鉴于您问题中的代码链接,问题似乎出在这里:Serial::Serial(cha

c++ - 等同于 "typename",表示从属名称确实是 'template template parameter'

我们将无法找到正确语法的部分代码缩减为最小示例。让我们假设以下定义(不用担心“为什么”;)templateclassElement{};templateclass>classClient{};templatestructTemplatedProvider{templateusingelement_template=Element;};现在,从C++11开始,我们可以使用类模板或类型别名模板来实例化Client模板。以下函数编译得很好:voidfun(){Clientclient;Client::element_template>clientBis;}但在以下情况下,当给Client的模

C++ - 为什么 std::function<some_type_t, void> 无效?

在C++中,如果我尝试这样做:std::function然后编译器会抛出错误。为什么是这样?它在许多情况下很有用。一个例子://g++-std=c++17prblm.cpp#include#includetemplateclasssome_callback{public:usingcallback_t=std::function;some_callback(callback_t_myfunc){this->myfunc=_myfunc;}callback_tmyfunc;};usingcallback_with_just_bool=some_callback;usingcallback

c++ - 重载 << 运算符错误 C2804 : binary 'operator <<' has too many parameters

这是我的类(class):#ifndefCLOCK_H#defineCLOCK_Husingnamespacestd;classClock{//MemberVariablesprivate:inthours,minutes;voidfixTime();public://Getter&settormethods.voidsetHours(inthrs);intgetHours()const;voidsetMinutes(intmins);intgetMinutes()const;//ConstructorsClock();Clock(int);Clock(int,int);//CopyC

c++ - '从 some_type** 到 const some_type** 的无效转换'

我有一个函数需要constsome_type**作为参数(some_type是一个结构,函数需要一个指向这种类型数组的指针).我声明了一个some_type*类型的局部变量,并对其进行了初始化。然后我将该函数称为f(&some_array),编译器(gcc)说:error:invalidconversionfrom‘some_type**’to‘constsome_type**’这里有什么问题?为什么我不能将变量转换为常量? 最佳答案 参见:Whycan'tIpassachar**toafunctionwhichexpectsaco

C++ 方法重载 : base and derived parameters

在网上搜索后,我没有设法找到这个问题的答案:我有这个重载方法:foo(Base*base);foo(Derived*derived);在这种情况下,“Derived”是“Base”的子类。当我打电话时:foo(newDerived());我注意到总是调用第一个重载方法,而我想获得相反的结果(调用以“Derived*”对象作为参数的方法)。如何解决?谢谢。编辑:好的,这是我的实际情况:我有一个UIWidget和一个UIScoreLabel类。UIScoreLabel派生自UIWidget。我还有一个GameEvent类(Base)和一个P1ScoreGameEvent类(Derived)

c++ - boost asio 中的并发读取和 async_read_some

假设在boost::asio中的套接字上启用了async_read_some服务,如果在同一套接字上调用阻塞读取会发生什么情况?一段伪代码如下:usingboost::asio::local::stream_protocol;boost::asio::io_serviceio;stream_protocol::sockets(io);s.connect(stream_protocol::endpoint(address));s.async_read_some(aBuffer,aCallback);//startasync_readboost::threadthread(boost::b