Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Interview questions

Reply
Thread Tools

Interview questions

 
 
CFG
Guest
Posts: n/a
 
      06-21-2004
I still don't understand why you've picked this question?
Just for the sake of the fancy term "POD", which you already know?

This question is definitely not the best single question about C++.




 
Reply With Quote
 
 
 
 
Ioannis Vranos
Guest
Posts: n/a
 
      06-21-2004
CFG wrote:

> I still don't understand why you've picked this question?
> Just for the sake of the fancy term "POD", which you already know?
>
> This question is definitely not the best single question about C++.



As I said it would be one question of the many to determine the depth of
the candidate's knowledge. There would be simpler ones too. Since he
asked for a question that he could be asked, I chose to provide a
difficult one and not an easy one, that it would be certain he would
answer. And he learned new things, so why is it bad?






Regards,

Ioannis Vranos
 
Reply With Quote
 
 
 
 
Ioannis Vranos
Guest
Posts: n/a
 
      06-21-2004
cj wrote:

> Dear friends, I have one more questions for everyone in the newsgroup:
>
> I am preparing for an interview on UNIX/C++. Could you please identify some
> of the most important questions which might be asked, so that I could best
> prepare for it?




Another interesting question that I would ask, in the advanced level
this one.




In a class hierarchy with virtual member functions, how much does the
time cost of calling a virtual function increases while the depth of
abstraction increases?


For example:


class base1
{
// ...
virtual void something();
};

class base2: public base1
{
// ...
void something();
};

//...

class base999999: public base999998
{
// ...
void something();
};


base1 *p1=new base78;

p1->something();


base1 *p2=new base999999;

p2->something();



How much more time it takes for the implementation to find and invoke
base999999::something() in comparison to base78::something()?






Regards,

Ioannis Vranos
 
Reply With Quote
 
E. Robert Tisdale
Guest
Posts: n/a
 
      06-21-2004
Ioannis Vranos wrote:

> Another interesting question that I would ask
> in the advanced level is this one.
>
> In a class hierarchy with virtual member functions,
> how much does the time cost of calling a virtual function increases
> while the depth of abstraction increases?
>
> For example:
>
> class base1 {
> // ...

public:
> virtual void something(void);
> };
>
> class base2: public base1 {
> // ...

public:
> void something();
> };
>
> //...
>
> class base999999: public base999998 {
> // ...

public:
> void something();
> };
>
> base1 *p1=new base78;
>
> p1->something();
>
> base1 *p2=new base999999;
>
> p2->something();
>
> How much more time it takes
> for the implementation to find and invoke base999999::something()
> in comparison to base78::something()?


It depends upon the implementation (compiler).
In the typical implementation, it takes no more time.
The C++ computer programming language standard
does *not* specify implementations, performance or efficiency.
 
Reply With Quote
 
Peter Koch Larsen
Guest
Posts: n/a
 
      06-21-2004

"Ioannis Vranos" <(E-Mail Removed)> skrev i en meddelelse
news:cb79ll$2r98$(E-Mail Removed)...
> cj wrote:
> > Dear friends, I have one more questions for everyone in the newsgroup:
> >
> > I am preparing for an interview on UNIX/C++. Could you please identify

some
> > of the most important questions which might be asked, so that I could

best
> > prepare for it?
> >
> > Thank you,
> > C++J

>
>
>
> Here is one I would ask:
>
>
> Is the following code guaranteed to be safe and portable?
>
>
>
> #include <string>
> #include <vector>
> #include <cstddef>
>
> int main()
> {
> using namespace std;
>
> class A
> {
> vector<int>array;
> string s;
>
> public:
> A():array(100){}
> }a;
>
>
> unsigned char *p=reinterpret_cast<unsigned char *>(&a);
>
> unsigned char *v=new unsigned char[sizeof(a)];
>
>
> for(size_t i=0; i<sizeof(a); ++i)
> v[i]=p[i];
> }
>



I do believe that that question is a very bad one. The code above is
obviously portable, but these casts do confuse. What on earth are you going
to do with v? Any programmers instinct is that code must have "a use", and
it is quite difficult to see what you could portable do with v. Also, the
reinterpret_cast is to a non-const pointer which chould also give all of us
an uneasy feeling. Don't do that against those poor could-be collegues!

Kind regards
Peter


 
Reply With Quote
 
Peter Koch Larsen
Guest
Posts: n/a
 
      06-21-2004
"Ioannis Vranos" <(E-Mail Removed)> skrev i en meddelelse
news:cb7q6g$1540$(E-Mail Removed)...
> cj wrote:
>
> > Dear friends, I have one more questions for everyone in the newsgroup:
> >
> > I am preparing for an interview on UNIX/C++. Could you please identify

some
> > of the most important questions which might be asked, so that I could

best
> > prepare for it?

>
>
>
> Another interesting question that I would ask, in the advanced level
> this one.
>
>
>
>
> In a class hierarchy with virtual member functions, how much does the
> time cost of calling a virtual function increases while the depth of
> abstraction increases?
>

[snip]
>
>
> How much more time it takes for the implementation to find and invoke
> base999999::something() in comparison to base78::something()?
>
> Regards,
>
> Ioannis Vranos


That one was much better!

/Peter


 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      06-22-2004
E. Robert Tisdale wrote:

>> How much more time it takes for the implementation to find and invoke
>> base999999::something()
>> in comparison to base78::something()?

>
>
> It depends upon the implementation (compiler).
> In the typical implementation, it takes no more time.
> The C++ computer programming language standard
> does *not* specify implementations, performance or efficiency.




Wrong. Next please.






Regards,

Ioannis Vranos
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      06-22-2004
Ioannis Vranos wrote:

> E. Robert Tisdale wrote:
>
>>> How much more time it takes for the implementation to find and invoke
>>> base999999::something()
>>> in comparison to base78::something()?

>>
>>
>>
>> It depends upon the implementation (compiler).
>> In the typical implementation, it takes no more time.
>> The C++ computer programming language standard
>> does *not* specify implementations, performance or efficiency.

>
>
>
>
> Wrong. Next please.



But I forgot to give you a reference. "The C++ Programming Language" 3rd
Edition or Special Edition, page 324.






Regards,

Ioannis Vranos
 
Reply With Quote
 
JKop
Guest
Posts: n/a
 
      06-22-2004
Peter Koch Larsen posted:

> I do believe that that question is a very bad one. The code above is
> obviously portable, but these casts do confuse. What on earth are you
> going to do with v? Any programmers instinct is that code must have "a
> use", and it is quite difficult to see what you could portable do with
> v.


What ever happened to just having fun?

int main(void)
{
int monkeys[7] = { 3, 4 ,3, 2 ,2 ,34, 23 ,3 };

char jack reinterpret_cast<char>(monkeys[5]);

cout << jack;
}
 
Reply With Quote
 
JKop
Guest
Posts: n/a
 
      06-22-2004
JKop posted:

> Peter Koch Larsen posted:
>
>> I do believe that that question is a very bad one. The code above is
>> obviously portable, but these casts do confuse. What on earth are you
>> going to do with v? Any programmers instinct is that code must have "a
>> use", and it is quite difficult to see what you could portable do with
>> v.

>
> What ever happened to just having fun?
>
> int main(void)
> {
> int monkeys[7] = { 3, 4 ,3, 2 ,2 ,34, 23 ,3 };
>
> char jack reinterpret_cast<char>(monkeys[5]);


TYPO

char jack = reinterpret_cas<char>(monkeys[5]);


>
> cout << jack;
> }
>


 
Reply With Quote
 
 
 
Reply

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
Please come and add questions to C++ interview questions onListenVoice Vijay C++ 2 05-07-2010 03:02 PM
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
Needed real interview questions marathikaka@yahoo.co.in Microsoft Certification 3 09-07-2005 12:11 AM
Interview Questions Vishal Pandey ASP .Net 0 11-24-2003 02:00 PM



Advertisments