Hello there peoples! How are ya! Can anyone here help me with a little problem I have?
I am trying to create class with a member pointer, but when i try to dereference it the program crashes, but i dont get any error message from the compiler. Here is the code:
this is the class, constructor and function. When i try to set age i get error. Can anyone help me?Code:class TEST { public: Test(); //constructor int GetAge () const; void SetAge (int age); private: int * pAge; }; TEST::Test() { int * pAge = new int; } void TEST::SetAge(int age) { *pAge = age; }