473,466 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Linker error with pure virtual method

2 New Member
Hello,

I have a base class with a private method declared as
virtual bool Initialize() = 0;

My derived class inherits from this base class -privately- (it implements a public interface, as well -- there is no method in the other base class called Initialize).
The derived class supplies bool Initialize() (in the private section -- it also provides a definition). However, the linker tells me "unresolved external" regarding the Initialize in the base class. Any thoughts?

In case it helps, I'll state the problem in its original form. Originally, the base class implemented a default Initialize (ie, the method was of the form 'virtual bool Initialize();' with a trivial definition of return true; ). This method was overridden in my derived class by supplying 'bool Initialize()' and a non-trivial definition. However, I was encountering problems with the class wherein parts of it were not, in fact, being initialized -- stepping through with a debugger revealed that only the base class's Initialize (ie, 'return true;') was being called, not the derived class's. I double-checked -- the actual type is of the derived class. Thoughts?

Thanks!
Feb 28 '07 #1
2 3975
Banfa
9,065 Recognized Expert Moderator Expert
Somewhere you are constructting a object of the base calss type where you shouldn't be.
Feb 28 '07 #2
melkins2002
2 New Member
All,

Nevermind, I figured it out. I was calling the Initialize from the base class constructor (erf, a novice mistake!) -- but of course, the derived class is not fully constructed at that time, so it naturally calls the base class version.

Thanks!
Feb 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Bob Bamberg | last post by:
Hello All, I have been trying without luck to get some information on debugging the Runtime Error R6025 - Pure Virtual Function Call. I am working in C++ and have only one class that is derived...
11
by: santosh | last post by:
Hello, I was going through the Marshal Cline's C++ FAQ-Lite. I have a doubt regarding section 33.10. Here he is declaring a pure virtual destructor in the base class. And again defining...
3
by: Chucker | last post by:
Hi Folks, I got a Wrapper Dll around a native C++ static library. In .NET 1.1 this worked fine. When moving to .NET 2.0 I get a couple of unresolved externals / linker errors: Error 16 error...
4
by: Mark | last post by:
Hi, I'm trying to write some classes that kind of manage themselves. A linked list, that links different types of objects. Here's the code... object.h: --- class Object { int alt;
1
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly,...
1
by: toton | last post by:
In C++ , when the class is declared in the header & not implemented in the cpp, the linker is not giving a error untill the method gets called. How to ensure that all non pure-virtual method...
10
by: John Goche | last post by:
Hello, page 202 of Symbian OS Explained by Jo Stichbury states "All virtual functions, public, protected or private, should be exported" then page 203 states "In the rare cases where a...
3
by: keith | last post by:
Dear mentors and gurus, I noticed at the end of section 22.4 of the 'FAQ-Lite' it says "Note that it is possible to provide a definition for a pure virtual function, but this usually confuses...
3
by: Rahul | last post by:
Hi Everyone, I have the following polymorphic classes, class Shape { public : virtual void draw() { } virtual void sample();
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
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
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.