I'm trying to allocate dynamic memory to an array of objects, but I keep getting the following error:
"error: C2143: syntax error : missing ';' before '*'" "error: C2501: 'Figura' : missing storage-class or type specifiers"
Any help is welcomed. I'm using Visual Basic C++ 2006, but will switch to Turbo C++ 3.0 with Dosbox to get graphics.h working :( .
Here's the code:
#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) {
}