草庐IT

Membership_Level_Name

全部标签

c++ - syntax::function_name 在 C++ 中是什么意思?

在名为::foo()的函数中,我不明白语法的用途。如果它是foo::count_all()那么我知道count_all是类或命名空间foo的函数。在::foo()的情况下,::引用的是什么? 最佳答案 ::运算符正在调用namespace或class。在您的情况下,它正在调用全局命名空间,它是不在命名空间中的所有内容。下面的例子说明了为什么namespace很重要。如果您只是调用foo(),您的调用将无法解析,因为有2个foo。您需要使用::foo()解决全局问题。namespaceHidden{intfoo();}intfoo()

C++ 编译错误枚举 "does not name a type"

以下代码:foo.h#include"bar.h"classfoo{public:enummy_enum_type{ONE,TWO,THREE};foo();~foo(){}};foo.cppfoo::foo(){inti=bar::MY_DEFINE;}酒吧.h#include"foo.h"classbar{public:staticconstintMY_DEFINE=10;foo::my_enum_typevar;bar(){};~bar(){};};让g++编译器提示my_enum_type“没有命名类型”。为什么?所有header都有多个包含定义(为清楚起见,此处未显示)。谢谢

C++ : Read a file name from the command line and utilize it in my file

如何从命令行读取文件名并在我的C++代码文件中使用它?例如:./cppfileinputFilenameoutputFilename非常感谢任何帮助! 最佳答案 intmain(intargc,char**argv){stringinFile="";stringoutFile="";if(argc==3){inFile=argv[1];outFile=argv[2];}else{cout 关于C++:Readafilenamefromthecommandlineandutilizeiti

c++ - Bison and doesn't name 类型错误

我有以下文件:CP.h#ifndefCP_H_#defineCP_H_classCP{public:enumCardinalite{VIDE='\0',PTINT='?',AST='*',PLUS='+'};CP(CardinalitemyCard);virtual~CP();private:Cardinalitecard;};#endif/*CP_H_*/和dtd.y%{usingnamespacestd;#include#include#include#include"AnalyseurDTD/DtdDocument.h"#include"AnalyseurDTD/CP.h"voi

C++ 函数名称分解 : What does this name suffix mean?

当我反汇编Chromium二进制文件时,我注意到有一些函数以这种模式命名:_ZN6webrtc15DecoderDatabase11DecoderInfoD2Ev.part.1如果我把这个字符串给c++filt,输出是webrtc::DecoderDatabase::DecoderInfo::~DecoderInfo()[克隆.part.1]那么这个.part.1后缀的真正含义是什么?如果它表明同一个函数有多个拷贝,他们为什么需要那个?是因为位置独立的要求吗?我使用g++作为编译器。 最佳答案 它表示析构函数是partialinli

c++ - getline(cin.name) 被跳过

我从C++中的一个函数调用一个函数,该函数具有getline(cin,name)行,其中name是一个字符串。第一次通过循环时,程序不等待输入。它将通过循环的所有其他传递。有什么想法吗?voidgetName(string&name){intnameLen;do{cout 最佳答案 确保自上次从cin读取内容后没有遗漏,例如:在你的程序的前面一点:intnumber;cin>>number;您提供的输入:5程序后面:getline(cin,name);和getline似乎不会被调用,而是它收集了您上次输入时的换行符,因为当您使用ci

c++ - '简历' : a namespace with this name does not exist while building (VS 2015, OpenCV 3.2)

在VS2015中构建一个简单的OpenCV应用程序时出现错误'cv':anamespacewiththisnamedoesnotexistwhilebuilding虽然我相信我已经完成了为VS配置OpenCV所需的所有步骤(使用本文作为引用http://opencv-srf.blogspot.com/2013/05/installing-configuring-opencv-with-vs.html)类(class)的开始很简单#include"opencv2/imgcodecs.hpp"#include"opencv2/highgui.hpp"#include"opencv2/sti

c++ - (C++14) lambda 数组 : error: 'name' declared as array of 'auto'

我很难解决这个错误。我承认,我是C++的新手,我的困难来自于不理解错误消息。代码如下:autoselectionFuncs[8]={[&](constVector3&min,constVector3&max){returnmax.x_==seamValues.x_||max.y_==seamValues.y_||max.z_==seamValues.z_;},[&](constVector3&min,constVector3&max){returnmin.x_==seamValues.x_;},[&](constVector3&min,constVector3&max){returnm

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++ - "Expected class-name"...析构函数实现中的问题

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