C++ error: forward declaration
来源:互联网 发布:硬盘坏了怎么恢复数据 编辑:程序博客网 时间:2024/05/24 07:38
c++各个对象之间要相互调用,从A对象调B对象的成员函数,方法是forward declaration,如下面的例子:
//file1.h declaration of A
class A
{
public:
A();
~A();
void fun();
........
private:
........
};
//file1.h end!
//file1.cpp definition of A
A::A()
{
.....
}
A::~A()
{
.....
}
A::fun()
{
........
}
//file1.cpp end!
要在class B 里调用A;则B可以如此
//file2.h declaration of B
class A;
class B
{
public:
B();
~B();
// void function(){a->fun();};
......
private:
A* a;
........
}
//file2.h end!
//file2.cpp
B::B()
{......}
B::~B()
{......}
.........
//file2.cpp end
注意: class B 声明里面" // void function(){a->fun();};"前面的注释"//"不能去掉,否则会有error: forward declaration,编译通不过,也就是不能有对B对象的操作
- C++ error: forward declaration
- error forward declaration of xxx
- error: forward declaration of 'class QLabel'
- error :parameter has just a forward declaration
- IOS Dev Intro - Object C Forward Declaration
- enum forward declaration
- forward declaration问题
- forward declaration 前置声明
- C Error: mixed declaration and codes.
- c++:error qualification in declaration of '....'
- 前置声明(Forward declaration)
- C++ - Forward Declaration(前置申明)
- 前置声明(Forward declaration)
- 前向声明(forward declaration)
- c++ class forward declaration demo
- 前向声明(Forward Declaration)
- error: invalid use of incomplete type 'XXXX' ;error: forward declaration of 'XXXX' 声明改为包含头文件
- forward declaration of 'struct WebCore:: 错误
- 求职嵌入式软件开发linux kernel/BSP leader/工程师职位
- 被误传千年的七句经典名言
- URL和HTML编码
- jforum架构和主要配置文件的说明
- 读写csv 文件
- C++ error: forward declaration
- Inventor中管理Attribute的工具
- Pb读硬盘序列号和加密rsa算法
- C#正则表达式浅谈(转载)
- SQLite3 for WinCE or Mobile (EVC篇)
- 学习傅立叶变换从做开始
- fail-fast机制
- typedef的用法简介(三)
- 如何编程实现打开一个链接 ShellExecute()