Class error

Hi

1
2
3
4
5
6
7
8
9
10
11
class Camera
{
    double mouseposx = 0, mouseposy = 0;
    double xzdir = 0, ydir = 0, x, y, z;
public:
    void Camera(void)
    {
        glfwGetCursorPos(window, &mouseposx, &mouseposy);
        cout << mouseposx << " " << mouseposy;
    };
};


return type specification for constructor invalid -- line 6
Last edited on
A constructor and destructor have no return types.

1
2
3
4
5
   Camera()
    {
        glfwGetCursorPos(window, &mouseposx, &mouseposy);
        cout << mouseposx << " " << mouseposy;
    };


And normally in C++ if a function has no parameters you use empty parentheses(), not (void).

Last edited on
I dont want a constructor, I want just a function that works with that object. I put void there, hoping may solv the problem, because I saw people usong it
Ups, I just realised, how blind I'm, I gave the funtion the same name...as the class...........
I don't want a constructor

Then don't name the function the same as your class. That is what makes it a constructor.
Topic archived. No new replies allowed.