草庐IT

c++ - make 失败,返回错误 "cannot convert ‘std::istream {aka std::basic_istream<char>}’ 到 ‘bool’”

我正在尝试从源代码编译libgtextutils(fastxtoolkit需要)。“./configure”命令运行良好,但随后的“make”命令产生了一个我无法解决的错误。text_line_reader.cpp:Inmemberfunction‘boolTextLineReader::next_line()’:text_line_reader.cpp:47:9:error:cannotconvert‘std::istream{akastd::basic_istream}’to‘bool’inreturnreturninput_stream;^~~~~~~~~~~~make[3]:*

c++ - "expected nested-name-specifier before ‘const’ 错误“在 g++ 中类型名称为 const

我在C++中有这段代码templateclassDD:publicenumerables{...private:typenameconstDD&mContainer;}它给了我两条错误信息:错误:在“const”之前需要嵌套名称说明符错误:“&”标记前的声明符无效typenameconst有什么问题?代码?它使用MSVCC++编译得很好。已添加typenameDD&constmContainer;和consttypenameDD&mContainer;给我同样的错误。 最佳答案 那么,typename在那里做什么?您指的不是嵌套类型

c++ - g++ 在 ‘(’ token 之前预期不合格 ID

我在使用STL_vector.h时遇到此错误。我在Linux上使用g++进行编译。{if(max_size()-size()max_size())?max_size():__len;}usr/include/c++/4.5/bits/stl_vector.h:1143:40:error:expectedunqualified-idbefore‘(’token我不确定为什么会收到此错误,我搜索了很多并发现了一些“类似”的问题,但我无法解决我的问题。编辑:所以这是错误日志:Infileincludedfrom/usr/include/c++/4.5/vector:65:0,from../.

c++ - 从 ‘const char*’ 到 ‘char*’ [-fpermissive] 的无效转换

int::cadenacalculatelenght(constcadena&a,constchar*cad){cadenac;intlenght=0;char*punt;punt=cad;while(*punt){lenght++;punt++;}returnlenght;}我有这个问题,我想计算C字符串的长度而不使用像strlen这样的函数,在我的cadena类的其他方法中我可以,因为它不是constchar*,但现在我不知道该怎么办。 最佳答案 您可以将punt声明为正确的类型:constchar*punt=cad;

C++,从 ‘char’ 到 ‘const char*’ 的无效转换

在C++中我有这个程序:#includeusingnamespacestd;intmain(){stringexpression_input;cout我收到以下错误:prog.cpp:15:error:invalidconversionfrom‘char’to‘constchar*’prog.cpp:15:error:initializingargument2of‘std::basic_string&std::basic_string::insert(typename_Alloc::rebind::other::size_type,const_CharT*)[with_CharT=ch

C++: "error: expected class-name before ‘{’ token"继承模板类时

我四处寻找问题的解决方案,发现了很多关于循环引用和namespace的问题(均不适用于我的情况),但与我遇到的问题完全不同。我在maths/matrix.h中定义并实现了一个模板类:templateclassMatrix{public://constructors,destructorsandwhatnot...};我在maths/vector.h中定义并实现了另一个模板类#includetemplateclassVector:publicMatrix{public://constructors,destructorsandwhatnot...};我在vector.h中收到此错误“ex

c++ - 如何修复错误 : unknown type name ‘namespace’

#ifndefUNO_ACTION_#defineUNO_ACTION_namespaceUno{namespaceGame{classGame;}}//namespacenamespaceUno{namespaceAction{using::Uno::Game::Game;classAction{public:virtualboolisDisposeable()=0;virtualvoidtakeAction(Game*game)=0;virtual~Action(){}};}}#endif我在ubuntu12.04上编译这些代码,它返回错误集:action.h:4:1:error:

c++ - 错误 : invalid initialization of non-const reference of type ‘bool&’ from an rvalue of type ‘std::vector<bool>::reference {aka std::_Bit_reference}’

为什么我会收到错误:从类型为“std::vector::reference{akastd::_Bit_reference}”的右值对类型为“bool&”的非常量引用进行无效初始化?vector>vis;bool&visited(intx,inty){returnvis[x][y];//error}据我所知,vector中的operator[]返回引用,所以它应该是一个左值,但它不起作用。我应该怎么做才能让它发挥作用? 最佳答案 那是因为std::vector不是它看起来的样子。std::vector有一个特化与类型bool-它是空间

c++ - 错误 : ‘list’ is not a member of ‘std’ and error: template argument 2 is invalid

我正在尝试编译我的头文件,但我遇到了我无法弄清楚的错误。我想创建一个包含3个映射的结构:-从单个单词映射到计数-从词对映射到计数-从单个单词映射到后续单词列表我的头文件中的代码:#include#include#include#include#include#include#include#includetypedefstruct{std::mapfirstCounts;std::mappairCounts;std::map>follows;//Youcanuseaniteratortoretrievethevaluesstoredinthelist.}LanguageModel;我得

c++ - 错误 :‘itoa’ 未在此范围内声明

这个问题在这里已经有了答案:error:`itoa`wasnotdeclaredinthisscope(3个答案)关闭4年前。我收到以下错误:prog.cpp:在成员函数‘voidSequence::GetSequence()’中:prog.cpp:45:错误:“itoa”未在此范围内声明我已经包含了cstdlib头文件,但它不起作用。#include#include#include#include#include#includeusingnamespacestd;templatestructpredicate:publicbinary_function{booloperator()(