ICode9

精准搜索请尝试: 精确搜索
  • c – 名称查找和类范围2019-10-08 19:09:05

    为什么setVal的返回类型是string类型,参数类型是double类型 typedef string Type; Type initVal(); class Exercise { public: typedef double Type; Type setVal(Type); Type initVal(); private: int val; }; Type Exercise::setVal(Type parm) { val

  • c – ADL是调用朋友内联函数的唯一方法吗?2019-09-30 16:05:38

    让我们在S的声明中定义f作为S的友元函数: struct S { friend void f() {} }; 我找不到办法打电话给f. 那么,这样的内联朋友函数只能用argument-dependant lookup调用吗? struct S { friend void f() {} friend void g(S const&) {} } const s; int main() { // f

  • c – 在类中定义的友元函数的完全限定名称是什么?2019-09-30 09:05:19

    在类中定义的友元函数的完全限定名称是什么? 我最近看到了一个类似于以下的例子.以下val()的完全限定名称是什么? #include <iostream> namespace foo { class A { int x; public: A(int x = 0) : x(x) { } friend int val(const A &a) { return

  • 具有不同范围的其他相同名称的C名称解析规则2019-08-28 01:08:18

    我意识到以下是可怕的风格,但为了争论,假设我有以下代码: struct parent { virtual ~parent() {} }; struct child : public parent { child() {} virtual ~child() {} }; struct anotherClass { static parent& anyName; }; child anyName; // create an instance

  • 为什么class :: class :: class :: staticClassMember()编译(在C中)?2019-07-31 01:05:52

    我一定错过了C规范中的一些东西,因为我无法解释为什么以下代码成功编译: class MyClass { static void fun(); }; int main() { MyClass::MyClass::MyClass::fun(); } 有人能指出我的标准还是只是解释一下语义?我猜想只允许一个MyClass ::.两个MyClass :: MyClass ::应该导致错误.

  • c普通查找与参数依赖查找2019-07-27 07:06:09

    考虑http://en.cppreference.com/w/cpp/language/adl中描述的此示例: namespace A { struct X; struct Y; void f(int); void g(X); } namespace B { void f(int i) { f(i); // calls B::f (endless recursion) } void g(A::X x) {

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有