Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > error C2309: '{ctor}': is not a member of...

Reply
Thread Tools

error C2309: '{ctor}': is not a member of...

 
 
todd@weismannwebservices.com
Guest
Posts: n/a
 
      03-18-2007
Here is the portion of my code giving a problem:

#include <cassert>
#include <iostream>
using namespace std;

template <class BaseData>
class ListNode
{
BaseData listdata;
ListNode *link;

};

template <class BaseData>
class linklist {

protected:
ListNode<BaseData> *current, *head;

public:
//The class has the following required member functions:
//1. Insert an item in numerical order
void ordered_insert(const BaseData&);
//2.Determine if the List is empty
int listempty();
//3.Search the list for an item and remove it
void search_remove(BaseData);
//4.Return the number of items in the list
int listcount();
//5. Insert an item at the beginning of the list.
void insert_beg(BaseData);
//6. Insert an item at the end of the list.
void insert_end(BaseData);
//7. Return and remove an item from the end of the list
BaseData rt_end_value();
//8. Return and remove an item from the beginning of the list
BaseData rt_beg_value();
//9. Return an Item from the list
BaseData rt_value();
//10. Moves pointer to the next item
void move_next();
//to print out the list for the driver program
//overload stream insertion operator
friend ostream & operator<<(ostream&, const linklist<BaseData>&);
//These were done in class but I did not use
int beg_list();
int at_end();


};


template <class BaseData>
linklist<BaseData>::linklist()
{
head = NULL;
current = head;
}//this is the line the problem is on but I would guess the input
stream operator overloading is the problem

template <class BaseData>
ostream& operator<<(ostream& osObject, const linklist<BaseData>& list)
{
current = list.head;

while(current != NULL)
{
osObject<<current-<info<<" ";
current = current->link;
}
return osObject;
}

The problem is I am receiving an error: error C2309: '{ctor}': is not
a member of 'linklist<BaseData>'

I have included iostream so I know that is not the problem. I just
can not figure it out. Any one have any ideas. I have marked the
line the error comes up on.

 
Reply With Quote
 
 
 
 
kwikius
Guest
Posts: n/a
 
      03-18-2007
On 18 Mar, 20:45, t...@weismannwebservices.com wrote:

<...>

> template <class BaseData>
> class linklist {


//#######################
// add declaration of ctor in class definition ...
linklist();
//###############
/*
....
*/
};

<...>


> The problem is I am receiving an error: error C2309: '{ctor}': is not
> a member of 'linklist<BaseData>'


regrads
Andy Little



 
Reply With Quote
 
 
 
 
kwikius
Guest
Posts: n/a
 
      03-18-2007
On 18 Mar, 21:00, "kwikius" <a...@servocomm.freeserve.co.uk> wrote:
> On 18 Mar, 20:45, t...@weismannwebservices.com wrote:
>
> <...>
>
> > template <class BaseData>
> > class linklist {

>
> //#######################
> // add declaration of ctor in class definition ...


// hmm... probably want it public too ..

public:
> linklist();
> //###############


 
Reply With Quote
 
todd@weismannwebservices.com
Guest
Posts: n/a
 
      03-18-2007
On Mar 18, 5:01 pm, "kwikius" <a...@servocomm.freeserve.co.uk> wrote:
> On 18 Mar, 21:00, "kwikius" <a...@servocomm.freeserve.co.uk> wrote:
>
> > On 18 Mar, 20:45, t...@weismannwebservices.com wrote:

>
> > <...>

>
> > > template <class BaseData>
> > > class linklist {

>
> > //#######################
> > // add declaration of ctor in class definition ...

>
> // hmm... probably want it public too ..
>
> public:
>
> > linklist();
> > //###############




Thanks for the help...I did figure that out and felt a little stupid
afterwards but now I am having a new error when linking. The
overload of the insertion operator must be having a problem after
all. My cout's in main for a linklist object are outputting errors
when linking. The erros are:

Error 1 error LNK2019: unresolved external symbol "class
std::basic_ostream<char,struct std::char_traits<char> > & __cdecl
operator<<(class std::basic_ostream<char,struct std::char_traits<char>
> &,class linklist<int> const &)" (??6@YAAAV?$basic_ostream@DU?

$char_traits@D@std@@@std@@AAV01@ABV?$linklist@H@@@ Z) referenced in
function _wmain assignment4.obj


Error 2 fatal error LNK1120: 1 unresolved externals F:\CS
255\assignment4\Debug\assignment4.exe 1


 
Reply With Quote
 
todd@weismannwebservices.com
Guest
Posts: n/a
 
      03-18-2007
And I did fix:
osObject<<current-<info<<" ";
to:
osObject<<current->info<<" ";

Already


 
Reply With Quote
 
todd@weismannwebservices.com
Guest
Posts: n/a
 
      03-19-2007
On Mar 18, 5:48 pm, t...@weismannwebservices.com wrote:
> On Mar 18, 5:01 pm, "kwikius" <a...@servocomm.freeserve.co.uk> wrote:
>
>
>
> > On 18 Mar, 21:00, "kwikius" <a...@servocomm.freeserve.co.uk> wrote:

>
> > > On 18 Mar, 20:45, t...@weismannwebservices.com wrote:

>
> > > <...>

>
> > > > template <class BaseData>
> > > > class linklist {

>
> > > //#######################
> > > // add declaration of ctor in class definition ...

>
> > // hmm... probably want it public too ..

>
> > public:

>
> > > linklist();
> > > //###############

>
> Thanks for the help...I did figure that out and felt a little stupid
> afterwards but now I am having a new error when linking. The
> overload of the insertion operator must be having a problem after
> all. My cout's in main for a linklist object are outputting errors
> when linking. The erros are:
>
> Error 1 error LNK2019: unresolved external symbol "class
> std::basic_ostream<char,struct std::char_traits<char> > & __cdecl
> operator<<(class std::basic_ostream<char,struct std::char_traits<char>> &,class linklist<int> const &)" (??6@YAAAV?$basic_ostream@DU?
>
> $char_traits@D@std@@@std@@AAV01@ABV?$linklist@H@@@ Z) referenced in
> function _wmain assignment4.obj
>
> Error 2 fatal error LNK1120: 1 unresolved externals F:\CS
> 255\assignment4\Debug\assignment4.exe 1


I changed the ostream declaration to:
template <class BaseData> friend ostream & operator<<(ostream&, const
linklist<BaseData>&);
and that fixed it.

 
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
Why can derived member function not access protected member of a baseclass object? blangela C++ 8 09-26-2008 03:24 PM
error C2614: 'CYYYRegister' : illegal member initialization:'CRequest' is not a base or member Angus C++ 1 03-06-2008 11:38 AM
why const member, reference member can only be initialized not assigned ww C++ 4 10-26-2007 11:22 AM
parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function! ken C++ 2 06-28-2005 06:57 AM
How would I use qsort to sort a struct with a char* member and a long member - I want to sort in order of the long member Angus Comber C Programming 7 02-05-2004 06:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57