Yo,
I had a job interview today, the interviewing asked me about
inline virtual functions, or what was my opinion on them.
Hm, I've seen mention of these babies in the reference material,
but I've never used one. ( I'm an experienced software developer
and have used C++ for more than 10 years)
Anybody found the use of one of these guys necessary or useful.
Curious minds need to know for the next curve ball question coming my
way....!
thanks, dave
Jul 22 '05
15 10643
John Carson wrote: ... I had a job interview today, the interviewing asked me about inline virtual functions, or what was my opinion on them. Hm, I've seen mention of these babies in the reference material, but I've never used one. ( I'm an experienced software developer and have used C++ for more than 10 years) ... I think this was a trick question. Virtual function calls are only resolved at runtime and cannot be inlined.
"Inline function" and "inlined function call" are two different and
relatively independent things in C++. The same applies to "virtual
function" and "virtual (dynamically resolved) function call".
The question specifically mentions "inline virtual functions" and make
no reference to function calls whatsoever. Formally, there's absolutely
nothing tricky about it.
--
Best regards,
Andrey Tarasevich
Risto Lankinen wrote: Also remember that the inline function-specifier (implicit or explicit) is only a recommendation.
See 7.1.2.
However, inline has a second meaning as a linkage directive!
If you define a function in a header file (not a practice I would recommend, but for the sake of argument), then only one file in a multiple source file project may include that header, unless the definition is tagged as inline. Failing to do that, ambiguities in name resolution will emerge at link time. ...
Exactly. The same can be said about 'virtual'. It also has several
second meanings only loosely related to dynamically resolving function
calls.
When answering such questions, it is very important to understand the
difference between the properties of functions and the properties of
concrete function calls. Unfortunately, in many cases these two got
mixed together, which can only lead to confusion.
--
Best regards,
Andrey Tarasevich
"Andrey Tarasevich" <an************ **@hotmail.com> wrote in message
news:10******** *****@news.supe rnews.com John Carson wrote: ... I had a job interview today, the interviewing asked me about inline virtual functions, or what was my opinion on them. Hm, I've seen mention of these babies in the reference material, but I've never used one. ( I'm an experienced software developer and have used C++ for more than 10 years) ... I think this was a trick question. Virtual function calls are only resolved at runtime and cannot be inlined.
"Inline function" and "inlined function call" are two different and relatively independent things in C++. The same applies to "virtual function" and "virtual (dynamically resolved) function call".
The question specifically mentions "inline virtual functions" and make no reference to function calls whatsoever. Formally, there's absolutely nothing tricky about it.
We don't have the text of the interview question, just a paraphrase of it.
As I commented in response to Alf, I cannot think why the interviewer would
single out virtual functions for special mention unless (s)he was thinking
of the special inlining rules applicable to them.
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)
"Alf P. Steinbach" <al***@start.no > wrote in message
news:40******** ********@news.i ndividual.net And why do you think that the interviewer bothered to single out inline virtual functions as opposed to inline functions in general? The only reason that I can think of is because the rules for inlining are different.
It was an open question.
But not open enough to permit a discussion of inlining?
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)
"Andrey Tarasevich" <an************ **@hotmail.com> wrote in message
news:10******** *****@news.supe rnews.com Risto Lankinen wrote: Also remember that the inline function-specifier (implicit or explicit) is only a recommendation.
See 7.1.2.
However, inline has a second meaning as a linkage directive!
If you define a function in a header file (not a practice I would recommend, but for the sake of argument), then only one file in a multiple source file project may include that header, unless the definition is tagged as inline. Failing to do that, ambiguities in name resolution will emerge at link time. ...
Exactly. The same can be said about 'virtual'. It also has several second meanings only loosely related to dynamically resolving function calls.
When answering such questions, it is very important to understand the difference between the properties of functions and the properties of concrete function calls.
I would consider the former to be the union of the latter (and of the syntax
for declaring and defining the functions).
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)
* "John Carson" <do***********@ datafast.net.au > schriebt: "Alf P. Steinbach" <al***@start.no > wrote in message news:40******** ********@news.i ndividual.net And why do you think that the interviewer bothered to single out inline virtual functions as opposed to inline functions in general? The only reason that I can think of is because the rules for inlining are different.
It was an open question.
But not open enough to permit a discussion of inlining?
Oh, it is.
That too.
An open question can tell much.
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: qazmlp |
last post by:
My class in a header file, contains inline virtual destructor.
Is this Ok? Can it cause any problems?
class base
{
public:
base() { }
virtual ~base { std::cout<<"Inside virtual destructor\n"; }
// Other members
|
by: puzzlecracker |
last post by:
Is there a case where having an "inline function" is more effective and
less code i.e. code clean, but we still resort to use a regular
function for this purpose?
Another question, which I previously posted but answers were very
opinioned and not conclusive - Likely due to somewhat ambiguous
description in the first place. Sorry for repost!
|
by: Patrick Laurent |
last post by:
Hello
I have a program with many many inlined template functions
It is essential for the execution speed that every (or almost every)
function marked as inlined, becomes really inlined by the compiler.
I already compiled the program with Intel Compiler (ICL) on Visual C++, and
it works fine and fast. I verified that the functions are really inlined.
But with GCC 3.4 (Linux+Cygwin) or ICC (Linux), The same program is about 5
|
by: RainBow |
last post by:
Greetings!!
I introduced the so-called "thin-template" pattern for controlling the
code bloat caused due to template usage.
However, one of the functions in the template happens to be virtual as
well. To support thin-template, I need to make virtual function as
inline.
Now, I know that compiler would generate an out-of-line copy when it
|
by: siddhu |
last post by:
Dear experts,
A virtual function has to have an address. So if an inline virtual
function is actually inlined then in that case what does address of
this function signify? How does compiler know at compile time about
the actual object a pointer points to so that it can paste the correct
inline function in the place of function call if the function is
getting inlined?
| |
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,...
|
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,...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 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.
|
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...
| |