c++前向声明
2016-05-19 13:46
232 查看
前向声明的几种方式
前向声明
class A: A f();
详细类型声明
class A f();
两种方式的区别
前向声明struct s { int a; }; struct s; // does nothing (s already defined in this scope) void g() { struct s; // forward declaration of a new, local struct "s" // this hides global struct s until the end of this block s* p; // pointer to local struct s struct s { char* p; }; // definitions of the local struct s }
详细类型说明
class U; namespace ns{ class Y f(class T p); // declares function ns::f and declares ns::T and ns::Y class U f(); // U refers to ::U Y* p; T* q; // can use pointers and references to T and Y }
详细类型说明,只有在查找不到对应名字的同类型的东西,才会引入前向声明的效果。
相关文章推荐
- _USER_ERROR__missing_dlib_all_source_cpp_file__OR......
- 【C++】:C++中的继承权限和继承方式
- 【C++】:C++之this指针的作用
- C++多态性
- 顺序表的增加删除
- c++中的多态性
- 【C++】:C++的命名规则
- 【C++】:C++中的类成员访问权限
- c++ zlib实现gzip压缩字符串
- c++中指针和引用注意点整理
- 关于C++中结构体初始化小结
- 控制 C++生成随机数的范围
- android如何调用c++
- C++第六次实验——数组的操作。
- C++ 文件输入输出(三)
- C++第六次上机作业-矩阵求和
- c++第6次实验-项目2-数组合并
- c++第六次实验
- c++第6次试验
- c++第六次实验