jeudi 31 décembre 2015

the arrow '->' separator is crashing when calling function from class

I'm working on a project for class and I'm using classes and pointers of type class to call some functions in the class but it's crashing on Code Blocks and Eclipse and I don't know what is going on Note it crashes when assigning x with y

#include <iostream>

using namespace std;

class a{
private:
    int x;
public:
    void set_X(int y){
        x=y;
    }
};

int main()
{
    a *Ptr;
    Ptr->set_X(5);
}

Aucun commentaire:

Enregistrer un commentaire