Thursday, 9 November 2017

Shared library : When are they loaded

https://stackoverflow.com/questions/29285546/when-do-so-files-get-loaded-linux

Monday, 11 September 2017

Threads

http://www.cs.iit.edu/~cs561/cs450/ChilkuriDineshThreads/dinesh%27s%20files/User%20and%20Kernel%20Level%20Threads.html

http://www.geeksforgeeks.org/multithreading-c-2/


Kernel level threads are 100 times slower than user level threads as kernel need to manage other processes as well & a thread is a overhead for the kernel. It makes things more complex for the kernel.

Important C++ concepts

-static member functions can directly be accessed. No need to create class object for accessing static variables.
-static classes do not exist.

-private constructors:
private  constructors exist, private destructors do not.
private constructors are used to create a singleton class.
http://www.yolinux.com/TUTORIALS/C++Singleton.html

protected constructors also exist. They are created so that only child class can call its constructor.





Virtual Destructors:
virtual destructors exist in C++. If we have a derived class object stored in base class pointer & if we delete that pointer, it will be undefined behaviour. So, we use virtual destructors for this purpose.
http://www.geeksforgeeks.org/virtual-destructor/

virtual constructors do not exist as there will be no point creating an object whose constructor is virtual. Creating an object is a compile time decision.
Except inline no other keyword is allowed with constructors.


Copy Constructor:
http://quiz.geeksforgeeks.org/copy-constructor-in-cpp/
http://www.geeksforgeeks.org/copy-constructor-vs-assignment-operator-in-c/

http://www.geeksforgeeks.org/can-virtual-functions-be-private-in-c/

Smart pointer impementation + explicit keyword + conversion constructor

Exceptions Handling in C++



-If there is no catch statement for a try statement, then program ll not crash but will show abnormal behavior.

-try{
throw derived
}
catch(base){}
catch{derived}

The program will go in the base segment as it is written before derived statement.

-If you've one if/else block instead of one try/catch block, and if an exception throws in the try/catch block, then the if/else block is faster (if/else block: around 0.0012 milliseconds, try/catch block: around 0.6664 milliseconds). If no exception is thrown with a try/catch block, then a try/catch block is faster. But if you use 100 try/catch blocks in your program, and if one exception throws, then 100, if/else blocks, is faster.

static functions cannot be virtual

Abstract class, sizeof class with virtual function

If we do not override the pure virtual function in derived class, then derived class also becomes abstract class.
http://www.geeksforgeeks.org/pure-virtual-functions-and-abstract-classes/

Sizeof class with virtual function maintins a virtual pointer which increases sizeof class by pointer size - 8 bytes.