为什么尽管我声明了一个不完整类型的自动实例,但这段代码还是编译并运行
why does this code compile and run despite me declaring an automatic instance of incomplete type
从技术上讲,下面给出的代码不应该编译和运行,因为我已经声明了一个不完整数据类型的自动实例,但它确实编译和运行了。请有人帮我解码一下。
#include<iostream.h>
#include<conio.h>
void main()
{
class student;
student s;
getch();
}
class student
{
int age;
public:
student();
~student();
};
student::student()
{
age=14;
}
student::~student()
{
}`
它不是有效的ISO C++。
您的编译器可能会接受它,因为它不是ISO C++编译器
它是20世纪90年代早期的"C++"预标准版本的编译器。
ISO C++于1998年成立。在你不使用的语言中,合理化"技术上"应该发生什么或不应该发生什么是没有意义的。
相关文章:
- 在java中解决这段代码时面临循环中的问题
- 我是如何在这段代码中出现分段错误的
- 我不明白这段代码是如何对这个pythonlist()进行排序的,也不明白如何用C++中的向量来重现它
- 为什么这段代码不起作用,我该如何解决?
- 为什么这段代码给我错误? 有没有自错?
- 有人可以解释一下这段代码如何能够反转字符串
- 可能我知道为什么这段代码没有给出任何输出吗?
- 这段代码的最后一行在做什么?
- 我不知道为什么这段代码会让核心被转储?
- 我试图用这段代码找到二叉树的高度,但它一直返回 0,有人可以告诉我为什么吗?
- 有人可以向我解释一下这段代码的作用吗?
- 存储在哪个内存段(代码/数据段)类(员工)中?
- 为什么这段代码会导致无限循环?
- 任何人都可以弄清楚这段代码如何显示运行错误?它打印无限时间 -1 以及正确答案
- 如何为一段代码启用 -permissive
- 谁能告诉我为什么这段代码没有产生正确的输出?
- 我想反转我的阵列.为什么这段代码给出垃圾值?
- 使用Qt Creator在调试模式下编译一段代码
- 为什么尽管我声明了一个不完整类型的自动实例,但这段代码还是编译并运行
- 这段代码如何创建一个只有私有构造函数的类的实例?