C/C++ Interview Question: Why Executable file differs in size

I have following code snippets… Code snippet 1 int arr[1000000]; int main() { return arr[0]; } Code snippet 2: int arr[1000000] = {10}; int main() { return arr[0]; } After compilation of the above snippets the output exe differs in size. The second snippet’s executable is much bigger in size than the first snippet’s executable. […]
Continue reading…

 

Technical Interview Question: Is there a bug?

Is there a bug in the following C++ code snippet? class Base { public: Base() : m_pBaseIds(new int[200]) { } virtual ~Base() { DelPtrs(); } protected: virtual void DelPtrs() { delete [] m_pBaseIds; } private: int* m_pBaseIds; }; class Derived : public Base { public: Derived() : m_pIds(new int[100]) { } protected: virtual void DelPtrs() […]
Continue reading…