error C2027: use of undefined type 'A' see declaration of 'A'
来源:互联网 发布:万国数据科技公司电话 编辑:程序博客网 时间:2024/05/17 01:00
#include<iostream>using namespace std;class A;class B{public :B(A * a){a->c = 5;}};class A{public:int c;void set(){B b(this);cout<<c;}};void main(){A a;a.set();}/*error C2027: use of undefined type 'A'see declaration of 'A'error C2227: left of '->c' must point to class/struct/union*/
在定义类B之前,只是声明了类A,这个声明是前向声明,在类A声明之后,定义之前,类A 是不完整类型,即已知A是一个类型,但不知道包含哪些成员。对于不完整类型,只能定义一个A类型的指针或引用,且不能访问它的成员,因为编译器只知道有类A存在而不知道类A到底是什么。
0 0
- error C2027: useof undefined type 'A' see declaration of 'A'
- error C2027: use of undefined type 'A' see declaration of 'A'
- 编译openssl库时出现“error C2027: use of undefined type 'in6_addr'”的解决方法
- illegal use of this type as an expression see declaration of 'STACK'
- use of undefined type 'IActiveDesktop'
- see declaration of 'i'
- error: invalid use of incomplete type 'XXXX' ;error: forward declaration of 'XXXX' 声明改为包含头文件
- 错误: use of undefined type 'boost::STATIC_ASSERTION_FAILURE'
- ado控件 use of undefined type 'C_Recordset'
- 编译错误:error: invalid initialization of non-const reference of type ‘*&’ from a temporary of type
- error: invalid initialization of non-const reference of type ‘*&’ from a temporary of type
- c++ class forward declaration and invalid use of incomplete type
- error: creating array of references( declaration of 'a' as array)
- error: creating array of references( declaration of 'a' as array)
- A story of declaration and defintion (C++)
- error: a label can only be part of a statement and a declaration is not a statement
- ERROR:a label can only be part of a statement and a declaration is not a statement
- 【C/C++】error: a label can only be part of a statement and a declaration is not a statement
- zookeeper伪分布式集群环境搭建
- 有符号和无符号整型数据溢出问题
- 我爱智慧石!分享咯~
- 关于黑客公司被黑,这些隐情需要知道
- 利用Android studio开发JNI工程
- error C2027: use of undefined type 'A' see declaration of 'A'
- IOS后台运行 之 后台播放音乐
- iOS入门(十四)函数指针
- 关于Python的super用法研究
- gcc/g++使用简介
- 动态规划之 最优二叉搜索数 递归实现
- hdoj 1875 畅通工程再续 【最小生成树】
- UNIX网络编程卷一:第十一章 名字与地址转换
- 一个清华学生留学香港后对人生的思考