473,414 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

What does the standard say about this

I just spend about an hour tracking down a link error with GCC. I had
defined a virtual member function, but never referenced it. With this
declaration, the linker would complain that the virtual table for the class
was missing. I know that it is acceptable by the standard to declare a
non-virtual member but not define it, if it is never accessed. Is the same
true for virtual members?

Thanks,

DrX
Jul 22 '05 #1
1 1091
Xenos wrote in news:9D*******************@twister.nyroc.rr.com in
comp.lang.c++:
I just spend about an hour tracking down a link error with GCC. I had
defined a virtual member function, but never referenced it. With this
declaration, the linker would complain that the virtual table for the
class was missing. I know that it is acceptable by the standard to
declare a non-virtual member but not define it, if it is never
accessed. Is the same true for virtual members?


No, but you can declare the member pure-virtual, in which case
(as long as it isn't the destructor) you don't need a defenition.

However it makes the class *abstract*, i.e. you may not create
instances of it (even if you do provide a defenition).

struct X
{
virtual int f() = 0; /* = 0 means: pure */
};

struct Y : X
{
virtual int f();
};

int Y::f()
{
return 0;
}

int main()
{
Y y;
return y.f();
}

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #2

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

Similar topics

92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
2
by: Alexander Stippler | last post by:
Hi, what about "not a number"? What does the standard enforce, what not? I read in the C standard, that NAN is defined if and only if the implementation supports quiet NaNs for the float type....
10
by: tjgable | last post by:
I have some code that builds fine on .Net 2001(?).. VC++ 7.0. But with gcc 3.42 in MinGW and MS VC++ 6.0 it does not. I can understand VC++ not working, but isn't gcc standard yet? Here is the...
7
by: red floyd | last post by:
Given function pointer, say void (*func)(void*), what's the best way to display it on an iostream? as far as I can tell, there is no default overload for operator<<, and a function pointer...
20
by: Steven T. Hatton | last post by:
I just read this in the description of how C++ is supposed to be implemented: "All external object and function references are resolved. Library components are linked to satisfy external...
24
by: David Mathog | last post by:
If this: int i,sum; int *array; for(sum=0, i=0; i<len; i++){ sum += array; } is converted to this (never mind why for the moment):
2
by: Thomas G. Marshall | last post by:
Arthur J. O'Dwyer <ajo@nospam.andrew.cmu.edu> coughed up the following: > On Thu, 1 Jul 2004, Thomas G. Marshall wrote: >> >> Aside: I've looked repeatedly in google and for some reason cannot >>...
10
by: DJ | last post by:
What is printed to the screen? #include <stdio.h> int main(void) { printf("Hello!\n"); fclose(stdout); printf("Goodbye!\n"); return 0;
12
by: Benjamin B. | last post by:
Hi everyone, in this thing I inherited there's a statement like this: a &= ~b; where a is an int and b has been declared this way: const b = 0x0002;
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
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,...
0
isladogs
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...
0
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...

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.