C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pure functions still pure after definition

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Todd Aspeotis
Guest





PostPosted: Wed Apr 27, 2005 11:11 am    Post subject: Pure functions still pure after definition Reply with quote



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
Back to top
Rolf Magnus
Guest





PostPosted: Wed Apr 27, 2005 1:46 pm    Post subject: Re: Pure functions still pure after definition Reply with quote



Todd Aspeotis wrote:

Quote:
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 {
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"?

Quote:
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?

Quote:
Is there something I'm missing? Any help would be much
appreciated.


Back to top
Uenal Mutlu
Guest





PostPosted: Wed Apr 27, 2005 1:51 pm    Post subject: Re: Pure functions still pure after definition Reply with quote



"Todd Aspeotis" wrote
Quote:
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 {
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.



Back to top
Kanenas
Guest





PostPosted: Mon May 30, 2005 3:53 am    Post subject: Re: Pure functions still pure after definition Reply with quote

On 27 Apr 2005 04:11:28 -0700, [email]kawahee (AT) gmail (DOT) com[/email] (Todd Aspeotis)
wrote:

Quote:
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 {
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

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.