#include <iostream>
using namespace std;


class Dog
{
public:

Dog(int val){
 this->pVal = new int(val);
}

~Dog(){
 delete this->pVal;
}

static int GetVal(const Dog& d){
  return *(d.pVal);
}

int *pVal;
};

int main() {
Dog fido(20);
std::cout << Dog::GetVal(fido) << endl;  //20 and destructor for fido called
Dog rex(21);
std::cout << Dog::GetVal(fido) << endl; //21 but should be 20 
std::cout << Dog::GetVal(rex) << endl;   // should be 21

	return 0;
}