473,796 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Interview questions

cj
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 5950

"JKop" <NU**@NULL.NULL > wrote in message
news:UE******** *********@news. indigo.ie...
JKop posted:

char jack reinterpret_cas t<char>(monkey s[5]);


TYPO

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


'Tis not your day today... :-)

- Risto -
Jul 22 '05 #31
"E. Robert Tisdale" wrote:

Something that calls itself Default User wrote:

[nothing that has to do with C++.]
Unlike your post? Besides being a liar, you're a hypocrit.
Go away troll.


I'll make a deal with you. We'll have an on-line vote (not in the
group). Whoever gets the most votes as being a troll has to stop
posting.

You up for it, troll-boy?

Brian Rodenborn
Jul 22 '05 #32
Ioannis Vranos <iv*@guesswh.at .grad.com> wrote in message news:<cb******* ****@ulysses.no c.ntua.gr>...

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::som ething() in comparison to base78::somethi ng()?


Hi,
As a new C++ programmer, I found your question very interesting. I
think it takes about the same time to find and invoke
base78::somethi ng() and base999999::som ething(), right? Because each
object carries a virtual table pointer (if the class has at least one
virtual function) with an bunch of virutal function pointers to the
possible function definition. The lookup (not sure how the actual
virtual table is implemented but if it's something like a binary tree
or hash table then...) thus takes appr. the same amount of time.

If I answered it incorrectly, can you provide the answer? I want to
learn.

Thanks!
Jul 22 '05 #33
pembed2003 wrote:
How much more time it takes for the implementation to find and invoke
base999999::s omething() in comparison to base78::somethi ng()?

Hi,
As a new C++ programmer, I found your question very interesting. I
think it takes about the same time to find and invoke
base78::somethi ng() and base999999::som ething(), right? Because each
object carries a virtual table pointer (if the class has at least one
virtual function) with an bunch of virutal function pointers to the
possible function definition. The lookup (not sure how the actual
virtual table is implemented but if it's something like a binary tree
or hash table then...) thus takes appr. the same amount of time.

If I answered it incorrectly, can you provide the answer? I want to
learn.

Yes the time cost is the *same* regardless the depth of the abstraction.

As it is written in TC++PL on page 324:
"Classical hierarchies do tend to couple implementation concerns rather
strongly with the interfaces provided to users. Abstract classes can
help here. Hierarchies of abstract classes provide a clean and powerful
way of expressing concepts without encumbering them with implementation
concerns or significant run-time overheads. After all, a virtual
function call is cheap and independent of the kind of abstraction
barrier it crosses. It costs no more to call a member of an abstract
class than to call any other virtual function."


Regards,

Ioannis Vranos
Jul 22 '05 #34
pembed2003 wrote:
As a new C++ programmer, I found your question very interesting.
I think it takes about the same time to find and invoke
base78::somethi ng() and base999999::som ething(), right?
It depends upon the implementation.
But, yes, you are correct for typical implementations .
Because each object carries a virtual table pointer
(if the class has at least one virtual function)
with an bunch of virutal function pointers
to the possible function definition. The lookup
(not sure how the actual virtual table is implemented
but if it's something like a binary tree or hash table then...)
thus takes appr. the same amount of time.

If I answered it incorrectly, can you provide the answer?
I want to learn.


Actually, in Ioannis Vranos' example,
it appears that p1 and p2 are defined in the same scope
as the respective subsequent invocations of something(void) .
In this case, a good optimizing C++ compiler will emit code
to invoke the correct function directly
and will not even consult any virtual function table.
Jul 22 '05 #35
JKop <NU**@NULL.NULL > wrote in message news:<UE******* **********@news .indigo.ie>...
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_cas t<char>(monkey s[5]);


TYPO

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


cout << jack;
}


Hi,
I am trying to compile your code using g++ in FreeBSD. g++ -v gives:

gcc version 2.95.3 20010125 (prerelease)

the whole program looks like:

#include<iostre am>
using namespace std;
void main(void){
int monkeys[8] = {3,4,3,2,2,34,2 3,3};
char jack = reinterpret_cas t<char>(monkey s[5]);
cout<<jack<<end l;
}

but it won't compile:

g++ tmp.cpp -o tmp
tmp.cpp: In function `int main(...)':
tmp.cpp:5: reinterpret_cas t from `int' to `char'

I am trying to understand your program but failed. Can you tell me
what you are trying to demonstrate and what the program is supposed to
do? I am trying to learn.

Thanks!
Jul 22 '05 #36
pembed2003 wrote:
Hi,
As a new C++ programmer, I found your question very interesting. I
think it takes about the same time to find and invoke
base78::somethi ng() and base999999::som ething(), right? Because each
object carries a virtual table pointer (if the class has at least one
virtual function) with an bunch of virutal function pointers to the
possible function definition. The lookup (not sure how the actual
virtual table is implemented but if it's something like a binary tree
or hash table then...) thus takes appr. the same amount of time.

If I answered it incorrectly, can you provide the answer? I want to
learn.

Thanks!

I had problems with my server today, so I repost:

Yes the time cost is the *same* regardless the depth of the abstraction.

As it is written in TC++PL on page 324:
"Classical hierarchies do tend to couple implementation concerns rather
strongly with the interfaces provided to users. Abstract classes can
help here. Hierarchies of abstract classes provide a clean and powerful
way of expressing concepts without encumbering them with implementation
concerns or significant run-time overheads. After all, a virtual
function call is cheap and independent of the kind of abstraction
barrier it crosses. It costs no more to call a member of an abstract
class than to call any other virtual function."


Regards,

Ioannis Vranos
Jul 22 '05 #37
"E. Robert Tisdale" <E.************ **@jpl.nasa.gov > wrote in message news:<cb******* **@nntp1.jpl.na sa.gov>...
pembed2003 wrote:
As a new C++ programmer, I found your question very interesting.
I think it takes about the same time to find and invoke
base78::somethi ng() and base999999::som ething(), right?


It depends upon the implementation.
But, yes, you are correct for typical implementations .
Because each object carries a virtual table pointer
(if the class has at least one virtual function)
with an bunch of virutal function pointers
to the possible function definition. The lookup
(not sure how the actual virtual table is implemented
but if it's something like a binary tree or hash table then...)
thus takes appr. the same amount of time.

If I answered it incorrectly, can you provide the answer?
I want to learn.


Actually, in Ioannis Vranos' example,
it appears that p1 and p2 are defined in the same scope
as the respective subsequent invocations of something(void) .
In this case, a good optimizing C++ compiler will emit code
to invoke the correct function directly
and will not even consult any virtual function table.


Hi Robert,
Is the "good optimizing C++ compiler will emit code to invoke the
correct function directly" feature a standard behavior? ie, is it
mentioned and allowed by the C++ standard?

Thanks!
Jul 22 '05 #38
pembed2003 wrote in news:db******** *************** ***@posting.goo gle.com in
comp.lang.c++:
Actually, in Ioannis Vranos' example,
it appears that p1 and p2 are defined in the same scope
as the respective subsequent invocations of something(void) .
In this case, a good optimizing C++ compiler will emit code
to invoke the correct function directly
and will not even consult any virtual function table.


Hi Robert,
Is the "good optimizing C++ compiler will emit code to invoke the
correct function directly" feature a standard behavior? ie, is it
mentioned and allowed by the C++ standard?


The standard doesn't mention "virtual function table" so there
is no requirment that it be in the programme or that it be
consulted if it is.

The *only* requirment is that the correct function is called,
how that is achived doesn't matter.

Having said that, any programme can be optimised under the "as-if" rule.
i.e. as long as the programme behaves *as-if* the optimisation hadn't
been done then thats fine and dandy.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #39
"Ioannis Vranos" <iv*@guesswh.at .grad.com> wrote in message news:cb7t18$1c1 9
E. Robert Tisdale wrote:

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

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. :-)


What is wrong with Tisdale's answer (btw, is that the preferred short formal
name)?
Jul 22 '05 #40

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4105
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.
0
6171
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)
2
6970
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
0
4601
by: connectrajesh | last post by:
INTERVIEWINFO.NET http://www.interviewinfo.net FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES NO ADVERTISEMENT
2
7229
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
0
2669
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...
0
4515
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...
0
3433
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
0
2944
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
0
9680
marktang
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...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
jinu1996
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...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
agi2029
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...
0
5442
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...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.