Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Pure functions still pure after definition

Reply
Thread Tools

Pure functions still pure after definition

 
 
Todd Aspeotis
Guest
Posts: n/a
 
      04-27-2005
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
 
Reply With Quote
 
 
 
 
Rolf Magnus
Guest
Posts: n/a
 
      04-27-2005
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.


 
Reply With Quote
 
 
 
 
Uenal Mutlu
Guest
Posts: n/a
 
      04-27-2005
"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.


 
Reply With Quote
 
Kanenas
Guest
Posts: n/a
 
      05-30-2005
On 27 Apr 2005 04:11:28 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pure space directly inside div ignored, but pure space directlyinside span honored liketofindoutwhy@gmail.com HTML 4 03-29-2008 06:06 PM
Adding functions to classes after definition Gerard Brunick Python 0 01-09-2007 12:47 AM
private virtual functions and pure virtual functions with bodies John Goche C++ 10 12-08-2006 04:00 PM
can a class definition inside another class's definition Jianli Shen C++ 1 03-13-2005 06:02 PM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM



Advertisments