Interview Question


Country: United States




Comment hidden because of low score. Click to expand.
3
of 3 vote

There will be a problem if the class object is passed by value

should use smart pointer, not the regular one, or should define copy constructor and assignment operator (use deep copy, not shallow copy)

- Anonymous February 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
3
of 3 vote

m_pData is not initialized when constructing an Array object of size 0, so it will contain a random address. Upon destruction, the destructor will most likely find m_pData != NULL and try to delete that memory. Crash.

In other words, this will crash as soon as the program exits the block:

{
Array a(0);
}

- Anonymous February 27, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Why is the value nSize is passed to the base class even when there is no base class. ?? .. Still i m not sure.. what is the problem. :o

- Ash February 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

you don't have default con'tor which potentially cause error while compiling when you have
in main like:
Array<int> arr

- anand.k.prasad February 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I don't know a lot of C, but what does T(11) in the very last return statement means? I don't think that should be there.

- radu.cruceru February 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I don't know a lot of C/C++, but what does T(11) in the very last return statement means? I don't think that should be there.

- radu.cruceru February 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Cannot be used for types which dont have default/no args constructor

- Anonymous February 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Below are my findings.
1) Here the assignment operator need to overloaded to implement deep copy.
2) The whole solution could have been simply implemented using Vectors.

- Vijay Rajanna February 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The problem is that the data is an array of POINTERS . if you just delete[] you all forgetting to release also all allocated POINTERS in it . SO memory leak issue

- Eric Nantel April 23, 2015 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More