declaring objects in C++ vs java
问题 I have been using c++ for a while now and I am learning java, declaring objects in java is confusing me, In java we write myclass myobject = new myclass(); myobject.mymethod(); Is it same as this code in c++ ? myclass *myobject = new myclass(); myobject->mymethod(); i.e is the memory getting allocated on heap ? If it is on heap why we never free the memory. I believe the new keyword is the same. If so, how do we allocate memory on stack? 回答1: Is it same as this code in c++ ? Yes. It's the