为什么尽管我声明了一个不完整类型的自动实例,但这段代码仍然编译 运行
why does this code compile and run despite me declaring an automatic instance of incomplete type
从技术上讲,下面给出的代码不应该编译并且 运行,因为我已经声明了一个不完整数据类型的自动实例,但是 does.Please 有人可以为我解码它。
#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++ 编译器。
它是 1990 年代早期 "C++".
预标准版本的编译器
ISO C++ 于 1998 年问世。对于 "technically" 应该或不应该在您不使用的语言中发生的事情进行合理化是没有意义的。
从技术上讲,下面给出的代码不应该编译并且 运行,因为我已经声明了一个不完整数据类型的自动实例,但是 does.Please 有人可以为我解码它。
#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++ 编译器。
它是 1990 年代早期 "C++".
ISO C++ 于 1998 年问世。对于 "technically" 应该或不应该在您不使用的语言中发生的事情进行合理化是没有意义的。