草庐IT

reference_name

全部标签

c++ - 内联函数中的 undefined reference ,用一元 + 解决

我在启用c++11时遇到一个奇怪的gcc4.7问题:当我想编译这个时:constexprunsignedintgetDim(constinte){return(e==1)?A::Set::Dimension:((e==2)?B::Set::Dimension:((e==3)?C::Set::Dimension:(+D::Set::Dimension)));}其中对于每个结构A,B,C,D定义了Set的typedef,其中相关的Set有一个intDimension,例如structSetOne{staticconstintDimension=1;}structA{typedefSetOn

c++ - GLEW 和 glfw 编译错误 : undefined reference to symbol 'XConvertSelection'

我正在尝试编译这段代码:#include#include#include#includeGLFWwindow*window;#includeusingnamespaceglm;intmain(void){//InitialiseGLFWif(!glfwInit()){fprintf(stderr,"FailedtoinitializeGLFW\n");return-1;}glfwWindowHint(GLFW_SAMPLES,4);glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);glfwWindowHint(GLFW_CONTEXT_VERSION_MA

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

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

c++ - 转到特定页面后,如何将SwipeView的currentIndex设置为TabBar的currentIndex "by reference"?

我开始使用QtQuickControls2.0。我有使用C++的经验和少量的Qt经验,但我以前没有使用过QML。我有一个TabBar和一个SwipeView相互链接。我的意思是,当您在TabBar上选择一个页面时,SwipeView会转到该页面。当您从SwipeView滑动到一个页面时,TabBar会自行更新以反射(reflect)这一点。作为学习练习,我决定创建一个将用户转到第二页的按钮。问题是我似乎无法找到一种方法来做到这一点而不会弄乱TabBar和SwipeView之间的链接。下面的代码是我想出的最好的。它正确转到第二页,当我使用TabBar更改当前页面时,SwipeView仍会

c++ - std::reference_wrapper *this 周围

我有一个场景,我需要转换一个可以被*this链接的函数返回std::optional>而不是T&(原因超出了这个问题的范围)。我使用std::reference_wrapper的原因是因为std::optional不能引用,至少在C++11中不能。但是,这不起作用,因为我似乎遇到了终身问题。这是一个最小的例子:#include#includestructtest{std::reference_wrapperfoo(){val=42;return*this;}test&foo2(){val=50;return*this;}intval;};voidbar(testt){std::cout

c++ - Google 使用 SetUpTestCase 静态变量测试 undefined reference

我正在编写一个测试用例,它将有一个SetUpTestCase()方法,尽管我收到undefinedreference链接器错误,但该方法将分配一个共享资源。classParsingEventsTest:public::testing::Test{protected:staticxmleventXml;staticvoidSetUpTestCase(){ManagedObjectManagerSingleton::GET_SINGLETON().initializeTestEnvironment(PATH_TO_FILE);eventXml=*ManagerSingleton::GET_

c++ - gtest,对 'testing::Test::~Test()' 的 undefined reference ,testing::Test::Test()

我使用apt-getinstalllibgtest-dev安装了gtest我正在尝试检查它是否有效。所以我在eclipse中编写了简单的测试代码。但是有错误,undefinedreferenceto'testing::Test::~Test()'undefinedreferenceto'testing::Test::Test()'相反,如果我将ATest类的继承更改为protected,错误就会消失,但是出现其他错误testing::Testisinaccessiblebaseof'ATest_AAA_Test'怎么了?#include#includeclassA{public:int

c++ - 为 std::unordered_map 中的 const std::reference_wrapper 重载 operator==

我不知道如何使用std::reference_wrapper将std::string引用获取到std::unordered_map中>。根据以下链接,我知道我需要重载operator==。Whycantemplateinstancesnotbededucedin`std::reference_wrapper`s?但是,我不知道如何编写operator==以使其采用conststd::reference_wrapper。如果包装器不是const,那将不是问题。使用char而不是std::string效果很好(不需要重载operator==)。代码:#include#include#inc

c++ - gtest 的 undefined reference

为什么下面的ASSERT_EQ会导致undefinedreferencetoBar::kBar错误?编译:g++a.cc-lgtest-lpthread#includeclassBar{public:staticconstsize_tkBar=0;};TEST(Basic,Basic){ASSERT_EQ(0,Bar::kBar);}intmain(intargc,char**argv){testing::InitGoogleTest(&argc,argv);returnRUN_ALL_TESTS();} 最佳答案 来自Google

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