Recently, I ran into an interesting job interview question in C++ which I want to share. Lets take a look at the following code:

// Option A. 

char str1[] = "example";  

str1[1] = 'a';  

// Option B.  

char* str2 = "example";  

str2[1] = 'a';

What would happen if we compile and run this code ?


Continue Reading...

We use collections all the time. Many times we have to expose them to users of our classes. Lets look at this simple tree node class: class TreeNode { private List<TreeNode> children = new List<TreeNode>(); public IList<TreeNode> Children { get { return children; } } } The children need to be accessed by who ever […]


Continue Reading...