Posts

Showing posts from November, 2020

undefined reference to `vtable for Game'

 The problem to this is that, all the virtual for the table should be define. when the pointer reach the vtable, it ll search for all the references for the virtual function in the class. if it couldnot find it then the error "undefined reference to "vtable for Game" is given. The solution is to implement all the virtual function presented in the class and its sub classes as well. Stack overflow example. https://stackoverflow.com/questions/9406580/c-undefined-reference-to-vtable-and-inheritance

Smart Pointer

When ever you create a object of class, deconstructor will be called automatically, but when you make pointer of that class, the deconstructor won't be automatically  called. So you have to use smart pointer to de-allocate the memory. MyInt my_int ( 10 );  // This will call the destructor MyInt *my_int = new MyInt(10); // this won't automatically call the destructor Unique Pointer:  #include <memory> class MyInt { private : int x ; public : MyInt ( int p ) { x = p ; } ~MyInt () { std :: cout << " deconstructor " << std :: endl ; } int getData () { return x ; } }; int main() { // MyInt my_int(10); // std::cout << "My Int " << my_int.getData() << std::endl; std::unique_ptr<MyInt> p( new MyInt( 10 )); // Here the p will be created on stack not on heap std::cout << p->getData(); /

Task Specialization with method

Method declearation inside class. Methods body should be decleared outside the class. General function should be given with the template used in class like this:  typename Vector<T>::const_iterator Vector<T>::begin_z() const {     if (sz == 0) return end();     return const_iterator{values}; }  The same method can be specialized like this: Here, this method only execute when the template is Gossip_Girl. otherwise the above method is executed.  template<> Vector<Gossip_Girl>::const_iterator Vector<Gossip_Girl>::begin_z() const {     if (sz == 0) return end_z();           int lastIndexofBrooklyn = -1;           for(size_t i = 0; i < sz; i++) {             std::string area = to_string((values+i)->get_area());               if(area.find("Brooklyn") != std::string::npos) {                   lastIndexofBrooklyn = i;               }           }           if(lastIndexofBrooklyn == -1) return end_z();           return const_iterator{values+lastInde

Alma Cluster

1) login to: https://vpn.univie.ac.at/my.policy   2) route the traffic via the uni vpn   3) login to alma cluster from putty and filezilla alma.par.univie.ac.at login with username a11738090 and password ssh alma02 to change the cluster users to see the user in the same cluster To use the remote linux in clion  https://www.youtube.com/watch?v=A3yqpInZEGY&ab_channel=IbricaTutic GOTO tools, inside deployment, browse remote host. Enter username, password and alma.par.unive.ac.at. After the connection, remote file can be seen. To compile in remote host: toot, start ssh session.  Good to go now

remove all container from docker

sudo docker container rm -f $(sudo docker container ls -aq) sudo docker rmi $(sudo docker images -a -q)

for redirection error

you cannot use the container address to redirect, just like to post or get request: for e.g: return redirect("http://camera:80/config"), it will be an error return redirect("http://localhost:3100/config"), this is the right way to do that