Mar 7, 2022 at 6:54am Mar 7, 2022 at 6:54am UTC
Write your question here.
#include <iostream>
using namespace std;
class Shape {
public:
virtual Shape();
virtual void draw() const = 0;
virtual void rotate(int) = 0;
private:
short x_, y_;
};
class Circle : public Shape {
public:
void draw() const;
void rotate(int);
private:
int radius_;
};
void manipulation(Shape *sp) {
draw(sp);
rotate(sp, 12);
}
enum Type { CIRCLE, SQUARE, TRIANGLE, BLOB };
struct Shape {
Type type_;
short x_, y_;
};
void draw(Shape *);
void rotate(Shape *, int);
int main() {
output please;
}
Mar 7, 2022 at 8:19am Mar 7, 2022 at 8:19am UTC
Indeed.
The class Shape; struct Shape;
is an error. Two different types cannot have same identifier.
Mar 7, 2022 at 2:51pm Mar 7, 2022 at 2:51pm UTC
I'm feeling generous, your code with code tags (and some formatting to make it easier to read):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#include <iostream>
using namespace std;
class Shape
{
public :
virtual Shape();
virtual void draw() const = 0;
virtual void rotate(int ) = 0;
private :
short x_, y_;
};
class Circle : public Shape
{
public :
void draw() const ;
void rotate(int );
private :
int radius_;
};
void manipulation(Shape* sp)
{
draw(sp);
rotate(sp, 12);
}
enum Type { CIRCLE, SQUARE, TRIANGLE, BLOB };
struct Shape
{
Type type_;
short x_, y_;
};
void draw(Shape*);
void rotate(Shape*, int );
int main()
{
output please;
}
Constructors are never declared virtual. Ever. Your Shape ctor is declared wrong.
This isn't complete code, it shouldn't compile even when you fix the class/struct problem, there are missing function/class method definitions all over.
Just what are you trying to do in main?
Last edited on Mar 7, 2022 at 2:57pm Mar 7, 2022 at 2:57pm UTC
Mar 8, 2022 at 3:06am Mar 8, 2022 at 3:06am UTC
Thanks Seeplus, keskiverto. i am just looking for a correct way to output this code.
Last edited on Mar 8, 2022 at 3:06am Mar 8, 2022 at 3:06am UTC
Mar 8, 2022 at 6:16am Mar 8, 2022 at 6:16am UTC
What does "output code" mean?