Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Interview questions

 
 
Vladimir Shishkovsky
Guest
Posts: n/a
 
      06-21-2004
A agree with Rufus!!!

Do not prepare, just sleep and next day give answers on an interview
quastions.

Valdemar.


"Rufus V. Smith" <(E-Mail Removed)> сообщил/сообщила в новостях следующее:
news:(E-Mail Removed) s.com...
>
> "cj" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) s.com...
> > 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
> >

>
> Why are you being interviewed for a topic you know nothing about?
>
> Rufus
>
>



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

> Ioannis Vranos wrote:
>
>> Here is one I would ask:
>>
>> Is the following code guaranteed to be safe and portable?

>
>
> > cat main.cc

> #include <string>
> #include <vector>
> #include <cstddef>
>
> int main(int argc, char* argv[]) {
> using namespace std;
>
> class A {
> private:
> vector<int> array;
> string s;
>
> public:
> A(void): 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];
>
> return 0;
> }
>
> > g++ -Wall -ansi -pedantic -o main main.cc
> > ./main
> >

>
> Why would you ask such a question?
> What would you expect it to reveal?



It would be one of the many, in an effort to determine the depth of ISO
C++ knowledge. That one would be of the difficult ones.



>
> There is *no* guarantee that any code will be safe and portable.



There is, for 100% ISO C++ compliant compilers. Others have called you a
troll, but I have seen that you have actual C++ knowledge so let's try
to discuss seriously for once.



> Your code appears to comply with the ANSI/ISO C++ standard.
> It will port almost everywhere.
> Your code has no outputs and no persistent effects
> and is "safe" in that sense.




That code could be a part of a bigger program running 24h/24h.





>
> My first suspicion is that you don't really know what you are doing.
> I would be reluctant to accept any offer of employment
> that you might make.




You know, I have bought an anti-troll spray of a new brand.






Regards,

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

> Why would you ask such a question?
> What would you expect it to reveal?


I believe its intent was to bemuse.

> There is *no* guarantee that any code will be safe and portable.


Ofcourse there's a guarantee that code will be safe and portable. That's
what the Standard it all about.

> Your code appears to comply with the ANSI/ISO C++ standard.
> It will port almost everywhere.


It will compile, Yes. But according to the Standard, it contains undefined
behaviour. Crystal clear to me. It will *not* port.

> Your code has no outputs and no persistent effects
> and is "safe" in that sense.



Wrong, it's very very dirty.


> My first suspicion is that you don't really know what you are doing.



Wrong, he seems pretty proficient to me.


> Perhaps you were simply attempting to be "too clever".
> That's a common mistake for both programmers and managers.


blah blah blah

> If you want to test an applicant's C++ skills,
> ask them to write a simple C++ program
> or ask them to submit examples of C++ programs that they have written.


Very good.

But by trying to trick them you also see just how much of an understanding
they have. Consider hiring a car mechanic. Ask them the following question:
You should put deisel in a petrol car:
A) During winter, when the temperature is below zero
B) When the tank is more than half full

If they're an in-any-way-good mechanic, they'll spot the trick and shout,
"NEVER PUT DEISEL IN A PETROL CAR!"

> Don't test for understanding of subtle features of the language
> unless you really need a C++ language lawyer and,
> if you hire a C++ language lawyers,
> don't expect them to be very productive.
> You *will* be disappointed.


Unless ofcourse you ofter them money.


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

> E. Robert Tisdale wrote:
>>
>> There is *no* guarantee that any code will be safe and portable.

>
> There is, for 100% ISO C++ compliant compilers.


That's a lie.
No compiler developer offers such a guarantee.
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      06-21-2004
JKop wrote:


> It will compile, Yes. But according to the Standard, it contains undefined
> behaviour. Crystal clear to me. It will *not* port.



Ehehe, I think I must give the answer. Yes it *is* portable. The
standard guarantees that you can treat any object as an array of
unsigned chars of size the result of sizeof() of course (=bytes).


So you can cout the internals of any object!


Also for POD types (which can also be considered as plain char arrays)
it is guaranteed that if you copy them to a char, unsigned char array
you are getting valid objects exact copies of the original.


Consider the following code:


#include <iostream>
#include <cstddef>



int main()
{
using namespace std;

struct test
{
int x[10];

float y[10];
}x={ {0,1,2,3,4,5,6,7,8,9}, {0,1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9} };


unsigned char *y=new unsigned char[sizeof(x)];

unsigned char *xp=reinterpret_cast<unsigned char *>(&x);

for(size_t i=0; i<sizeof(x); ++i)
y[i]=xp[i];


test &r=reinterpret_cast<test &>(*y);


cout<<"r.x[]= ";
for(size_t i=0; i<10; ++i)
cout<<r.x[i]<<" ";

cout<<"\nr.y[]";
for(size_t i=0; i<10; ++i)
cout<<r.y[i]<<" ";

cout<<endl;
}



Isn't C++ cool?






Regards,

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

> Do not prepare,
> just sleep and next day give answers on an interview questions.


And, if you can't sleep,
just stay up all night pounding code and drinking beer.
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      06-21-2004
E. Robert Tisdale wrote:

> Ioannis Vranos wrote:
>
>> E. Robert Tisdale wrote:
>>
>>>
>>> There is *no* guarantee that any code will be safe and portable.

>>
>>
>> There is, for 100% ISO C++ compliant compilers.

>
>
> That's a lie.
> No compiler developer offers such a guarantee.



I still wonder. Since you like C++ why don't you participate seriously
in C++ discussions? If you do not like it, why are you here?






Regards,

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

> E. Robert Tisdale wrote:
>
>> Ioannis Vranos wrote:
>>
>>> E. Robert Tisdale wrote:
>>>
>>>> There is *no* guarantee that any code will be safe and portable.
>>>
>>> There is, for 100% ISO C++ compliant compilers.

>>
>> That's a lie.
>> No compiler developer offers such a guarantee.

>
> I still wonder.
> Since you like C++,
> why don't you participate seriously in C++ discussions?


I am serious. No one guarantees that
C++ programs which comply with ANSI/ISO standards are portable --
not compiler developers
and certainly not the ANSI/ISO C++ standard itself.
If you write an ANSI/ISO standard compliant C++ program
and claim that is ports to *any* platform, then *you*
and no one else will be held legally liable if it doesn't.
If you decide to make such a claim,
then you had better test it on the target platform[s] first.
 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      06-21-2004
Ioannis Vranos wrote:
>
> E. Robert Tisdale wrote:


[who cares what he wrote]

> I still wonder. Since you like C++ why don't you participate seriously
> in C++ discussions? If you do not like it, why are you here?



Because he's a troll. He likes to cause trouble. He posts incorrect or
incomplete information, especially targeting newbies. He changes the
text of quoted posts to make it seem as though people said something
different than they really did. People who disagree with him he labels
as trolls, this includes many of the knowledgable contributors on
comp.lang.c (where he's been more active of late, although he seems to
be switching back over here).

He earned the nickname Trollsdale.

Don't bother attempting to engage him in rational debate, he has no
interest in it.



Brian Rodenborn
 
Reply With Quote
 
E. Robert Tisdale
Guest
Posts: n/a
 
      06-21-2004
Something that calls itself Default User wrote:

[nothing that has to do with C++.]

Go away troll.
 
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