zoukankan      html  css  js  c++  java
  • 前向声名

    当需要在一个类中用到信赖自身的类定义时,需要用到前向声名,比如下面的例子,注意第1-3行,定义的就是IdlInterface的类,在该类本身就需要引用到InterfaceList但InterfaceList又信赖于IdlInterface,这种定义方法就是前向声名。

     1 class IdlInterface;
     2 typedef std::list<IdlInterface*> InterfaceList;
     3 typedef std::list<IdlInterface*>::iterator InterfaceIterator;
     4 
     5 class IdlInterface : public IdlType {
     6 
     7 private:
     8     /** All functions */
     9     FunctionList __functions;
    10     /** Old type's instance */
    11     InterfaceList __interfaces;
    12 
    13 public:
    14     /** Adds a new function to interface */
    15     void addFunction(IdlFunction*);
    16     /** Gets a pointer to current functions list */
    17     FunctionList* getFunctions();
    18 
    19     /** Adds a new interface */
    20     void addInterface(IdlInterface*);
    21     /** Gets the interface reference */
    22     InterfaceList* getInterfaces();
    23 
    24     /** Casts to std::string for convenience of printing */
    25     std::string toString();
    26 };
  • 相关阅读:
    php的date对象与javascript的Date对象区别
    window.open的popup-only-once问题(document.cookie)
    window.open详解
    顶级窗口问题window.top
    javascript中的this用法
    问题1:javascript的函数对象问题
    javascript中this的用法
    javacsript:在函数内访问全局变量
    bzoj1934
    bzoj1433
  • 原文地址:https://www.cnblogs.com/Mento/p/2198707.html
Copyright © 2011-2022 走看看