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 };
  • 相关阅读:
    动态规划0-1背包问题
    在网页上加入运行代码的功能
    关于CSS基础框架的学习
    Hadoop综合大作业
    hive基本操作与应用
    用mapreduce 处理气象数据集
    熟悉常用的HBase操作,编写MapReduce作业
    爬虫大作业
    熟悉常用的HDFS操作
    数据结构化与保存
  • 原文地址:https://www.cnblogs.com/Mento/p/2198707.html
Copyright © 2011-2022 走看看