Posts

Showing posts from December 15, 2018

Return the address of a polymorphic object using a virtual function

Image
up vote 0 down vote favorite I have a polymorphic list of objets vector<Animal*> my_pets and my animal can be i.e a cat, a dog,or a tortoise. My dog or toirtoise have to point on a specific cat on the polymorphic list. my_pets.push_back(new Cat()) my_pets.push_back(new Dog(my_pets[0]->getAddress()); my_pets.push_back(new Tortoise(my_pets[0]->getAddress()); So the dog and the tortoise have to receive the address of the cat. The problem is that I don't know how to write the function(getAddress()) to get this address. I wanted to make a virtual function getAddress() so that I could use it in my polymorphic list but I struggle to get the right way to do that anybody could help please ? pointers polymorphism

Could I safely remove the build subdirectory after having compiled a program from sources?

Image
up vote 0 down vote favorite Description: When I compile a software from sources, I usually do it in the /opt folder (don't ask my why, I don't know) by running these commands; $ git clone < git url of the software > $ mkdir build; cd build $ cmake-gui .. => click on "configure" within cmake-gui => configure some paths or options (this may take some time and be tricky until I debugged all dependencies...) => click on "generate" within cmake-gui , then when everything worked fine; $ make -j4 $ sudo checkinstall Questions: I really like to keep the cloned sources if I later want to pull the new commits, but I wonder if I can safely remove the build/ sub-directory (which is using a lot of disk space sometimes)? Why? And if yes, how could I keep a