I'm implementing a class (or rather a Baseclass, and classes inherit from it), which holds a Integer. Now I have the problem, that I only can return the pointer to the value once.:
Inte foo =  Inte(5);
cout << foo.getValue() << endl; // 5
foo.setValue(10);
cout << foo.getValue() << endl; // 10   
cout << foo.getValue() << endl; // 4199696
The getValue function doesn't do anything, besides returning the pointer, I have no Idea why it returns 4199696 after the first getValue().
Here my class:
class Object {
public:
    virtual int getValue() = 0;
    virtual void setValue(int *pointer) = 0;
    virtual string toString() = 0;
};
class Inte : public Object {
private:
    int* value;
public:
        Inte (int *val){
            value = val;
        }
        Inte (int val){
            int a = val;
            value = &val;
        }
        virtual int getValue(){
            return *value;
        };
        virtual void setValue(int *pointer){
            value = pointer;
        };
        virtual void setValue(int val){
            int a = val;
            value = &val;
        };
        virtual string toString(){
            stringstream ss;
            string s;
            ss << value;
            ss >> s;
            return s;
        };
};
 
     
    