草庐IT

forward-declaration

全部标签

C++ 错误 : ‘_mm_sin_ps’ was not declared in this scope

我正在尝试对将函数应用于数组的不同方法进行基准测试。为什么是https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=3260,2124,4779,4779&cats=Trigonometry&text=_sin_mm_sin_ps在我的范围内未知,但_mm_sqrt_ps是?我如何让它为人所知?并编译无误。#include#include#include#include#include#include#include"immintrin.h"#includeintmain(){std::coutdis(-

c++ - 错误 : ambiguates old declaration ‘double round(double)’

/usr/include/i386-linux-gnu/bits/mathcalls.h:311:1:error:ambiguatesolddeclaration‘doubleround(double)’g.cpp:Infunction‘intround(double)’:g.cpp:14:24:error:newdeclaration‘intround(double)’/usr/include/i386-linux-gnu/bits/mathcalls.h:311:1:error:ambiguatesolddeclaration‘doubleround(double)’#includ

c++ - 在 C++ 中 : why does a constructor get called when an array of objects is declared?

MyClassmc2[]={MyClass(),MyClass()};//thiscallstheconstructortwiceMyClassmc1[4];//thiscallstheconstructor4times.Why?所以,我的问题是:为什么没有初始化的对象数组声明会导致调用默认构造函数? 最佳答案 在C++中,大小为4的MyClass数组是四个实际对象。它有点像包含该类型的四个成员的结构,当然您可以使用不同的语法访问这些成员,并且存在其他技术差异。因此,定义该数组导致构建4个对象的原因(并且在大致相同的情况下)与定义该

C++ 错误 : definition of implicitly-declared

我正在用C++编写这个链表程序当我测试程序时,我得到了错误linkedlist.cpp:5:24:error:definitionofimplicitly-declared'constexprLinkedList::LinkedList()'LinkedList::LinkedList(){这是代码链表.h文件:#include"node.h"usingnamespacestd;classLinkedList{Node*head=nullptr;intlength=0;public:voidadd(int);boolremove(int);intfind(int);intcount(i

c++ - C++模板函数中,依赖函数调用为什么报 "not declared"错误?

在C++模板函数foo()中,调用::bar(TT*)在gcc4.4.3下会出现以下错误:g++-ohello.o-c-ghello.cpphello.cpp:Infunction'voidfoo(std::vector>&)':hello.cpp:8:error:'::bar'hasnotbeendeclared这是有问题的代码://hello.cpp#includetemplatevoidfoo(std::vector&vec){TT*tt;::bar(tt);vec.push_back(tt);}classBlah{};voidbar(Blah*&){}intmain(intar

c++ - 为什么没有给 std::forward_list 一个 count() 成员函数?

我明白为什么std::forward_listdoesnothaveasize()memberfunction,因为O(1)版本会搞乱某些splice()的复杂性过载,并且由于O(N)version将与标准库的所有其他容器不一致。这也是事实std::list和std::forward_list已经有几个其他成员函数与中的表亲具有相同的语义标准库的一角(merge()、reverse()、remove()、remove_if()、unique()、sort())。那么为什么不是count()O(N)的成员函数提供给std::forward_list的复杂性具有返回std::distanc

C++ 构造函数 : Perfect forwarding and overload

我有两个类,A和B,B派生自A。A有多个构造函数(下例中有2个)。B有一个额外的成员要初始化(它有一个默认的初始化器)。我怎样才能实现B可以使用A的构造函数之一来构造,而不必手动重写B中A的所有构造函数重载?(在下面的示例中,否则我必须为B提供四个构造函数:B():A(){},B(strings):A(s){},B(intb):A(),p(b){},B(strings,intb):A(s),p(b){},而不是只有两个,至少在忽略默认参数的可能性时是这样)。我的方法是完美转发,但是下面的场景会报错:#include#includestructA{A(conststd::string&a

c++ - 错误 C2248 : 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'

我无法理解这个错误。这个错误不在我正在调试的类中。(是吗?)错误是:c:\programfiles\microsoftvisualstudio10.0\vc\include\fstream(890):errorC2248:'std::basic_ios::basic_ios':cannotaccessprivatememberdeclaredinclass'std::basic_ios'1>with1>[1>_Elem=char,1>_Traits=std::char_traits1>]1>c:\programfiles\microsoftvisualstudio10.0\vc\inc

c++ - 当两个类相互引用时编译 C++

我正在尝试围绕连接指针编写一个简单的包装器,当包装器被销毁时,它将把它返回到池中,但它不会编译,因为ConnectionPool和AutoConn需要彼此声明。我尝试使用向前减速但没有用。我该如何解决这个问题?(使用g++)classConnection{};classConnectionPool{Connection*m_c;public:AutoConngetConn(){returnAutoConn(this,m_c);//byvalue}voidreleaseConnection(Connection*c){}};classAutoConn{ConnectionPool*m_p

C++11 decltype : How to declare the type that a pointer points to?

我有以下代码:#includeintmain(){int*a=newint(2);std::unique_ptrp(a);}导致这些错误信息:Infileincludedfroma.cpp:1:Infileincludedfrom/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/memory:81:/usr/bin/../lib64/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../include/c++/4.9.2/bits/