好吧,这很有趣,我正在做一些事情,从笔记中获取了一堆代码,完全按照我发现它的方式复制并粘贴了它,而无需进行任何更改,这就是发生的事情...
代码:
#include <iostream>
using namespace std;
class Polygon {
protected:
int width, height;
public:
Polygon( int a=0, int b=0)
{
width = a;
height = b;
}
int area()
{
cout << "This is area as computed by the Polygon class" <<endl;
return 0;
}
};
class Rectangle: public Polygon{
public:
Rectangle( int a=0, int b=0):Polygon(a, b) { }
int area ()
{
cout << "This is area as computed by the Rectangle class" <<endl;
return (width * height);
}
};
int main( )
{
Polygon *polygon;
Rectangle rec(10,7);
polygon = &rec;
polygon->area();
return 0;
}
我像往常一样将其全部放在cpp文件中(即使用code :: blocks 20.03 btw,以及gnu c ++编译器的“ MinGW实现”,如果有帮助的话),我对其进行了编译,没有语法错误和结果我运行的exe文件是一个显示此内容的窗口,仅此而已:
处理返回32763(0x7FFB)执行时间:0.017 s
按任意键继续。
现在关于您的idk,我很确定我必须弄清楚这段代码有什么问题(如果不需要,请不要告诉我这是什么),但是如果我说实话,我没想到that这样的结果。
但是情况变得更糟,突然我收到了bitdefender通知,通知我:
项目已删除。威胁名称:Gen:Variant.Fugrafa.34286。路径:
C:\[...]\file.exe
创建的exe文件现在消失了,当我再次尝试编译代码时,出现错误,提示ld.exe cannot open file C:\[...]\file.exe Permission denied
和error: ld returned 1 exit status
我实际上比什么都好奇,这里出了什么问题?香港专业教育学院从来没有这种情况发生过!我的防病毒软件甚至在谈论什么威胁?我试图查找but there are literally zero search results on google。同样,当我尝试使用另一个代码更改源文件并再次编译时,我仍然遇到相同的错误。
[[我也只是在在线编译器上尝试过,结果只有这句话:
这是由Polygon类计算的面积
这就是为什么我认为我早先取得的一切根本毫无意义,即使代码中有错误。]