Potrzebuję pomocy przy programie wykorzystującym dziedziczenie wielobazowe. Program ma działać podobnie jak jest to przedstawione na schemacie:
Orłem z programowania nie jestem, więc proszę o wyrozumiałość. Tu wklejam swój kod. Niestety ale nie ustrzegłem się błędów:
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
class Point
{
protected:
int x, y;
public:
Point (int ax, int ay)
{
x = ax,
y = ay;
}
virtual void show()
{
cout << "(" << x << ", " << y << ")" << endl;
}
void print()
{
show();
}
};
class Text: public Point
{
protected:
char text[10];
public:
Text(char *atext, int atx, int aty): Point (atx, aty)
{
strcpy (text, atext);
}
void show()
{
cout << text;
}
void print()
{
show();
}
};
class TwoPoints: public Point
{
protected:
int x1, y1;
public:
TwoPoints (int ax, int ay, int ax1, int axy): Point(ax, ay)
{
x1 = ax1,
y1 = ay1;
}
void show()
{
cout << "(" << x << ", " << y << "), (" << x1 << ", " << y1 << ")" << endl;
}
};
class Rectangle: public TwoPoints
{
public:
Rectangle(int ax, int ay, int ax1, int ay1): TwoPoints(ax, ay, ax1, ay1)
{
}
void show()
{
cout << "(" << x << ", " << y << "), (" << x1 << ", " << y1 << ")" << endl;
}
};
class RectangleText: public Rectangle, public Text
{
public:
RectangleText(int ax, int ay, int ax1, int ay1, char* tx, intatx, intaty): Rectangle (ax, ay, ax1, ay1), Text(tx, atx, aty)
{
}
void show()
{
cout << "(" << TwoPoints :: x << ", " << TwoPoints :: y << ")" << "(" << x1 << ", " << y1 << ")" << text << "(" << Text :: y << ")"
<< "(" << x1 << ", " << y1 << ")" << text << "(" << Text :: x << ", " << Text :: y << ", " << endl;
}
};
void main ()
{
RectangleText R (5, 5, 100, 100, "RECTANGLE", 13, -13);
R.TwoPoints :: print();
cout << sizeof (RectangleText);
system("pause");
}