我正在尝试将动态内存分配给对象数组,但我不断收到以下错误:
“错误:C2143:语法错误:缺少';' 在“*”之前”“错误:C2501:“Figura”:缺少存储类或类型说明符”
欢迎任何帮助。我正在使用 Visual Basic C++ 2006,但将切换到带有 Dosbox 的 Turbo C++ 3.0 以使 graphics.h 工作:(。
这是代码:
#include<iostream.h>
class Grup {
private:
int nr_elemente;
Figura *figuri;
public:
Grup() {
figuri = new Figura[nr_elemente];
}
};
class Figura {
public:
Figura();
~Figura();
Figura(const Figura&);
friend Figura operator+(const Figura& fig1, const Figura& fig2) {};
friend Figura operator+(const Grup& gr1, const Grup& gr2) {}
friend Figura operator*(const Figura& fig) {}
friend Figura operator*(const Figura& fig) {}
};
Figura operator+(const Figura& fig, const Grup& gr) {
return fig;
}
class Punct : Figura
{
public:
int x, y;
Punct(int x, int y) {
Punct::x = x;
Punct::y = y;
}
};
class Segment : Figura
{
public:
int x, y, poz;
};
class Dreptunghi : Figura
{
public:
int x, y, poz;
};
void main(void) {
}