我最近发现使用using将基类函数导入派生类的名称空间(当它被隐藏时)。我试图用它来从基类导入功能的功能在派生类中实现: class A {
public:
virtual void foo() = 0;
};
class B {
public:
void foo() {
}
};
class C : public A, public B {
pub
我的理论是gcc有一个bug。 using type = const struct {}&;
但现在当我将其更改为右值引用它铿锵编译,但不能用gcc:在这两个铛和gcc以下编译 using type = const struct {}&&;
// main.cpp:8:17: error: expected ';' after struct definition
// typedef s
在[namespace.udecl]/10则有以下示例: namespace A {
int i;
}
namespace A1 {
using A::i;
using A::i; // OK: double declaration
}
void f() {
using A::i;
using A::i; // error: double
看一看下面的代码: struct A {
public:
virtual void f(){std::cout << "in A";};
};
struct B : A{
public:
virtual void f(){std::cout << "in B";};
int a;
};
struct C : B{
using A::f;
请考虑以下程序。根据C++标准是它良好的成立(该标准的相关部分引用所需的): namespace X { extern int i; }
namespace N { using X::i; }
int N::i = 1;
int main() {}
我得到不同的编译器不同的结果。我试图找出什么编译器我应该立案的bug报告: 锵:提供了以下编译器错误:没有名为“我”在命名空间“N”
,请参见下面的代码 struct A { using type = int; };
struct B : private A {};
struct C : B { using base_type = A; };
所有GCC 6.1,铛3.8和MSVC 2015年更新3拒绝编译这一点,因为A是不是因为里面C的访问名称A是B的私人基础。看来gcc认为A在using base_type = A是
Base::f(int)和Derived::f(int)之间的main()以下表达式d.f(1);中为什么没有含糊不清? class Base
{
public:
void f(int i) {}
void f(int i, int j) {}
};
class Derived : public Base
{
public:
using