473,395 Members | 1,637 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,395 software developers and data experts.

Pure functions still pure after definition

Hello all. I've been having some very weird compiler errors in regards
to my classes. I have my base node class here:

template <class T> class CNode : public CManaged
//-- Base node used to traverse either dynamic or static data
structures
//-- transparently.
{
public:
//-- Declarations:
typedef T baseType;
//-- Data:
T m_tData;
//-- Default constructor/destructor:
CNode();
~CNode();
//-- Transparent traversal:
inline virtual CNode<T> *getLeft() = 0;
inline virtual CNode<T> *getRight() = 0;

AUTO_SIZE;
};

And then later on down the track I have my dynamically overloaded
node:

template <class T> class CNode_Dynamic : public CNode<T>
//-- Node used to traverse a dynamic data structure. Derived from
CNode<T>.
{
public:
//-- Data:
CNode_Dynamic *m_pnLeft;
CNode_Dynamic *m_pnRight;
//-- Default constructor/destructor:
CNode_Dynamic();
~CNode_Dynamic();
//-- Transparent traversal:
inline CNode<T> *getLeft();
inline CNode<T> *getRight();

AUTO_SIZE;
};

Finally, I have the implementation of getLeft() and getRight() here:

template <class T> CNode<T> *CNode_Dynamic<T>::getLeft()
{
return m_pnLeft;
}

template <class T> CNode<T> *CNode_Dynamic<T>::getRight()
{
return m_pnRight;
}

Now, what VC++ . NET is telling me that it can't initiate an abstract
class of CNode_Dynamic<int> because I haven't defined getLeft or
getRight. Is there something I'm missing? Any help would be much
appreciated.

-- Todd
Jul 23 '05 #1
3 1361
Todd Aspeotis wrote:
Hello all. I've been having some very weird compiler errors in regards
to my classes. I have my base node class here:

template <class T> class CNode : public CManaged
//-- Base node used to traverse either dynamic or static data
structures
//-- transparently.
{
public:
//-- Declarations:
typedef T baseType;
//-- Data:
T m_tData;
//-- Default constructor/destructor:
CNode();
~CNode();
//-- Transparent traversal:
inline virtual CNode<T> *getLeft() = 0;
inline virtual CNode<T> *getRight() = 0;

AUTO_SIZE;
};

And then later on down the track I have my dynamically overloaded
node:

template <class T> class CNode_Dynamic : public CNode<T>
//-- Node used to traverse a dynamic data structure. Derived from
CNode<T>.
{
public:
//-- Data:
CNode_Dynamic *m_pnLeft;
CNode_Dynamic *m_pnRight;
//-- Default constructor/destructor:
CNode_Dynamic();
~CNode_Dynamic();
//-- Transparent traversal:
inline CNode<T> *getLeft();
inline CNode<T> *getRight();

AUTO_SIZE;
};

Finally, I have the implementation of getLeft() and getRight() here:
Where is "here"?
template <class T> CNode<T> *CNode_Dynamic<T>::getLeft()
{
return m_pnLeft;
}

template <class T> CNode<T> *CNode_Dynamic<T>::getRight()
{
return m_pnRight;
}

Now, what VC++ . NET is telling me that it can't initiate an abstract
class of CNode_Dynamic<int> because I haven't defined getLeft or
getRight.
What is telling you that? The compiler or the linker? What's the exact
message?
Is there something I'm missing? Any help would be much
appreciated.


Jul 23 '05 #2
"Todd Aspeotis" wrote
Hello all. I've been having some very weird compiler errors in regards
to my classes. I have my base node class here:

template <class T> class CNode : public CManaged
//-- Base node used to traverse either dynamic or static data
structures
//-- transparently.
{
public:
//-- Declarations:
typedef T baseType;
//-- Data:
T m_tData;
//-- Default constructor/destructor:
CNode();
~CNode();
//-- Transparent traversal:
inline virtual CNode<T> *getLeft() = 0;
inline virtual CNode<T> *getRight() = 0;

AUTO_SIZE;
};

And then later on down the track I have my dynamically overloaded
node:

template <class T> class CNode_Dynamic : public CNode<T>
//-- Node used to traverse a dynamic data structure. Derived from
CNode<T>.
{
public:
//-- Data:
CNode_Dynamic *m_pnLeft;
CNode_Dynamic *m_pnRight;
//-- Default constructor/destructor:
CNode_Dynamic();
~CNode_Dynamic();
//-- Transparent traversal:
inline CNode<T> *getLeft();
inline CNode<T> *getRight();

AUTO_SIZE;
};

Finally, I have the implementation of getLeft() and getRight() here:

template <class T> CNode<T> *CNode_Dynamic<T>::getLeft()
{
return m_pnLeft;
}

template <class T> CNode<T> *CNode_Dynamic<T>::getRight()
{
return m_pnRight;
}

Now, what VC++ . NET is telling me that it can't initiate an abstract
class of CNode_Dynamic<int> because I haven't defined getLeft or
getRight. Is there something I'm missing? Any help would be much
appreciated.


Several reasons:
You are using Microsoft's stuff which is not standards conform.
And, IMO Microsoft's .NET stuff needs another 5 years of fixing to become bugfree.
My advise is: to avoid such errors you should go strictly with ISO/ANSI/POSIX etc. standards.
Jul 23 '05 #3
On 27 Apr 2005 04:11:28 -0700, ka*****@gmail.com (Todd Aspeotis)
wrote:
Hello all. I've been having some very weird compiler errors in regards
to my classes. I have my base node class here:

template <class T> class CNode : public CManaged [...] inline virtual CNode<T> *getLeft() = 0;
inline virtual CNode<T> *getRight() = 0; [...]template <class T> class CNode_Dynamic : public CNode<T>
//-- Node used to traverse a dynamic data structure. Derived from
CNode<T>.
{
public: [...] inline CNode<T> *getLeft();
inline CNode<T> *getRight();

AUTO_SIZE;
};

Finally, I have the implementation of getLeft() and getRight() here:

template <class T> CNode<T> *CNode_Dynamic<T>::getLeft()
{
return m_pnLeft;
}

template <class T> CNode<T> *CNode_Dynamic<T>::getRight()
{
return m_pnRight;
}

Now, what VC++ . NET is telling me that it can't initiate an abstract
class of CNode_Dynamic<int> because I haven't defined getLeft or
getRight. Is there something I'm missing? Any help would be much
appreciated.


Does the error occur before or after the definitions of
CNode_Dynamic<T>::getLeft() and CNode_Dynamic<T>::getRight()? What if
you move the 'inline' specifier from the in-class declarations of
getLeft and getRight to the definitions? I may be way off with the
second question; I have no experience with MS's visual compilers but
am suspicious with how function specifiers interact with overloading
under VC++.

After playing around with similar code under g++ 3.3.2 and getting no
errors, I think it's a VC++ issue, not a language issue. See what
people have to say over in comp.os.ms-windows.programmer.*

Kanenas
Jul 23 '05 #4

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

Similar topics

7
by: A | last post by:
Hi, 1) Whats the difference from a virtual function and a pure virtual function? 2) When would you use one over the over? 3) What's the significance of the word virtual? Regards,
3
by: vasanth kumar | last post by:
I am writing a small example below. I want to know, is this allowed as per the standard C++. We make an abstract class by making any membor method as pure virtual. when we make it pure virtual,...
5
by: Steven T. Hatton | last post by:
This is a question about coding styles. I've seen some cases where the programmer has redeclared the pure virtual functions from an interface class in the implementation derived from it. For...
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...
37
by: WittyGuy | last post by:
Hi, I wonder the necessity of constructor and destructor in a Abstract Class? Is it really needed? ? Wg http://www.gotw.ca/resources/clcm.htm for info about ]
0
by: Kevin Bracey | last post by:
I've been implemening Annex F in my compiler, and one issue to do with "pure" functions has come to my attention. The compiler has for a long time had a __pure keyword (and a related pragma...
21
by: sks | last post by:
Hi , could anyone explain me why definition to a pure virtual function is allowed ?
7
by: sam_cit | last post by:
Hi Everyone, I wanted to know as to what is the exact difference between a virtual function and a pure virtual function? Thanks in advance!!!
6
by: Miguel Guedes | last post by:
Hello, I recently read an interview with Bjarne Stroustrup in which he says that pure abstract classes should *not* contain any data. However, I have found that at times situations are when it...
7
by: Tonni Tielens | last post by:
I'm trying to create a pure virtual class describing an interface. Normally, when I do this I make the destructor pure virtual so that, even if there are no members in the class, it cannot be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...

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.