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
Jul 22 '05
71 5945
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_cas t<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
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
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.
A agree with Rufus!!!
Do not prepare, just sleep and next day give answers on an interview
quastions.
Valdemar.
"Rufus V. Smith" <no****@nospam. com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:
news:c7******** *************** *******@news.te ranews.com... "cj" <cj@yahoo.com > wrote in message news:fd******** *************** *******@news.te ranews.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
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
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
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. :-)
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.
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
Something that calls itself Default User wrote:
[nothing that has to do with C++.]
Go away troll. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: softwareengineer2006 |
last post by:
All Interview Questions And Answers
10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP)
I have listed over 10000 interview questions asked
in interview/placement test papers for all companies between year
2000-2005
in my website
http://www.geocities.com/allinterviewquestion/
So please have a look and make use of it.
|
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
2000 Interview questions of .NET , JAVA and SQL Server Interview
questions (worth downloading it)
|
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
|
by: connectrajesh |
last post by:
INTERVIEWINFO.NET
http://www.interviewinfo.net
FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES
NO ADVERTISEMENT
|
by: freepdfforjobs |
last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions
http://www.questpond.com/SampleInterviewQuestionBook.zip
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
| |
by: freesoftwarepdfs |
last post by:
Ultimate list of Interview question website.....Do not miss it
http://www.questpond.com
http://msdotnetsupport.blogspot.com/2007/01/net-interview-questions-by-dutt-part-2.html
http://msdotnetsupport.blogspot.com/2006/08/net-windows-forms-interview-questions.html
http://msdotnetsupport.blogspot.com/2006/08/net-remoting-interview-questions.html
http://msdotnetsupport.blogspot.com/2006/08/c-interview-questions.html...
|
by: ramu |
last post by:
C# Interview Questions and Answers8
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html
C# Interview Questions and Answers7
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers7.html
C# Interview Questions and Answers 6
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers-6.html
C# Interview Questions and Answers 5...
|
by: reema |
last post by:
EJB Interview Questions
http://interviewdoor.com/technical/EJB-Interview-Questions.htm
CSS Interview Questions
http://interviewdoor.com/technical/CSS-Interview-Questions.htm
C Interview Questions
http://interviewdoor.com/technical/C-Interview-Questions.htm
C# Interview Questions
http://interviewdoor.com/technical/C-sharp-Interview-Questions.htm
C++ Interview Questions
http://interviewdoor.com/technical/C++-Interview-Questions.htm
|
by: reema |
last post by:
EJB Interview Questions
http://interviewdoor.com/technical/EJB-Interview-Questions.htm
CSS Interview Questions
http://interviewdoor.com/technical/CSS-Interview-Questions.htm
C Interview Questions
http://interviewdoor.com/technical/C-Interview-Questions.htm
C# Interview Questions
http://interviewdoor.com/technical/C-sharp-Interview-Questions.htm
C++ Interview Questions
http://interviewdoor.com/technical/C++-Interview-Questions.htm
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |