As the error is telling You, x is not an class or struct on which You are able to use the "."-operator...
c_str() is only a member of the std::string-type, so you need to pass your x and y-values into an string, or character first... (You need to convert the integer into an character)...
Create an stringstream object, pass in the values (dont forget an delimiter between them) and then return the string from it, on which you may call .c_str() instanly, too...
1 2 3
stringstream ss;
//get the c_str() out of ss
ss.str().c_str();
#ifndef BALL_H
#define BALL_H
#include <windows.h>
class Ball {
public:
Ball(POINT position, POINT speed, int height, RECT client);
void update();
void draw(HDC bbDC);
private:
POINT position;
POINT speed;
int height;
RECT client;
};
#endif
(For now, the project just has a ball bouncing at the walls - nothing more).
In the WM_CREATE message, I would like to make the ball object, passing in the speed and position (see the constructor). In C# it's possible to create this in the parameter, like this:
player = new player(new Point(75, 75));
Is this possible in my situation, in C++? It avoids creating a lot of objects which are only used for the constructor.
It is certainly possible, except you didn't define POINT as having a constructor that takes 2 arguments. Also, new returns a pointer to an object, not an object.
But why is a default constructor needed here? I never had to use one before. I've looked it up in the tutorial (http://cplusplus.com/doc/tutorial/classes/) but still don't understand why we need one in this case.