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 };
  • 相关阅读:
    内存中的线程
    python高级线程、进程和进程池
    生产者以及消费者模式(进程池)
    生产者以及消费者模式(多进程)
    生产者以及消费者模式
    全局解释器锁(GIL)
    JoinableQueue队列实现消费之生产者模型
    什么是Sikuli?
    协程基础
    装饰器
  • 原文地址:https://www.cnblogs.com/Mento/p/2198707.html
Copyright © 2011-2022 走看看