Ok I edit my code, what I want to do is simple I have a big shape with corrdinates(x,y). what I want to do is resize my primitive shape, store it inside new figure inside a class called "new" and move this new shape to the cordinates (x,y) I want.
// Example program
#include <iostream>
#include <string>
// Base class Shape
class Shape
{
public:
Shape(int inwidth, int inheight): width(inwidth), height(inheight){
}
void ResizeW(int w)
{
width = w;
}
void ResizeH(int h)
{
height = h;
}
void moveF(int x_delta, int y_delta)
{
x1 = x_delta;
y1 = y_delta;
x2 = x_delta;
y2 = y_delta;
}
protected:
int x1=0, y1=0, x2=5, y2=6;
int width;
int height;
};
// Primitive Shapes
class Ps2: public Shape
{
public:
Ps2 (int width, int height): Shape(width, height){
}
int getArea()
{
return (width * height);
}
};
// Derived Shapes
class New: public Ps2
{
int x1_relativ, y1_relativ, x2_relativ, y2_relativ;
public:
int area;
New(): Ps2(8, 4), area(getArea()){ }
};
int main(void)
{
New kit;
moveF.kit (4, 3, 5, 7);
std::cout << "Total area: " << kit.getArea();
std::cout << "Cordinates are: " << kit.moveF();
return 0;
}
Now I have four errors: In function 'int main()': 66:6: error: 'moveF' was not declared in this scope 68:51: error: no matching function for call to 'New::moveF()' 68:51: note: candidate is: 21:11: note: void Shape::moveF(int, int) 21:11: note: candidate expects 2 arguments, 0 provided. Also I don't think i'm able to use "move.f" I created any help?
Well, the compiler tells you exactly what the problem is:
moveF.kit (4, 3, 5, 7);
is no valid code. Did you mean kit.moveF? Also, why four parameters? moveF has two.
std::cout << "Cordinates are: " << kit.moveF();
has two errors, first, moveF requires two parameters which you don't provide, second, kit.moveF is a void and therefore will not produce anything that std::cout can display.
Also, your attributes x1, x2, y1, y2 can't be accessed from outside. This doesn't seem to be intended. A derived class could access them, but there is none that does right now.
Furthermore, New is a horrible name for a class. Confused me at first to see New kit;. New is obviously not reserved, but it feels reserved, if you know what I mean.
My advice is that you read a tutorial regarding classes and methods. It seems that your understanding how methods work is flawed.