+ 1
What is output of this code?
class MyClass{ private: int *data; int siz; public: MyClass(int sz) { this->siz=sz; data=new int[sz]; for(int i=0;i<sz;i++) data[i]=i+2; } int get_end() { return data[this->data[siz]]; } ~MyClass() { delete data; } }; int main() { MyClass a(4); MyClass b=a; cout<<b.get_end(); return 0; }
4 Réponses
+ 3
Why don't you try in Code Playground, what the output is?
+ 1
Thats it
+ 1
It's just a memory leak.