Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Some interview questions

Thread Tools

Some interview questions

Gernot Frisch
Posts: n/a
>> If you answer questions like these, you upset your possible boss.
> Who would want a technically incompentent person who believes she is
> technicallty competent, as boss?

Here in Germany unemployment rises. If you're in the east, you'll even
brush his shoes propably.

Reply With Quote
Posts: n/a
i totally agree with Mr Howard.....and i think ypu are absolutely right !!!
sorry for the mistake from my side!!

Reply With Quote
Posts: n/a
Sashi wrote:
> All, I had an interview today and I couldn't answer these questions.
> Any good answers?
> Why does a copy constructor param need to be const?

Technically, the parameter to a copy constructor _has_ to be
a const reference only if you will be copying from const

But I think most would agree that it's counter-intuitive for
a "copy" operation to change the thing that's being copied.
Making the parameter a const reference gives an assurance
that the source of the copy is not changed.

> Ever need a virtual constructor?

Yes. The inability to make a copy (outside the heap) of an object
when you only know its subclass is one of the limitations of
using virtual functions for generic code as opposed to templates.
But allowing virtual constructors or something equivalent for
stack variables would probably require drastic additions to
the language syntax. I don't see any way to do it without
breaking the rule (in Standard C/C++) that any object created
in the stack has a size known at compile time. (I don't
know what the value of this rule is, and GNU gcc has extensions
that break it anyway.) Hard to see how to use virtual constructors
for statically allocated variables because of the issue of the
size not being known at compile time.

> Major difference between public and private inheritance (other than the
> obvious one)?

They're _really_ deap sea fishing with this one. Some differences:

1) Can't address instances with pointer or reference to private
base class.

2) Even public members of private base class are inaccessable
in a dervived class instance from outside the derived class.

3) Can't be used to represent an "is-a" relationship (which is
basically saying the same thing as #1 but in a more non-obvious way).

> Thanks,
> Sashi

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Interview Questions ASP Interview Questions reema ASP General 0 08-26-2008 11:57 AM
.NET Interview Question, C#, ASP.NET Interview Questions dotnetuncle Javascript 0 10-30-2007 03:08 PM
Some Interview Questions Matt C Programming 18 10-30-2004 05:40 AM
Some Questions Asked in Interview Jatinder C Programming 50 05-24-2004 03:20 PM
some interview questions. pandapower C Programming 26 11-28-2003 04:13 AM