By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,851 Members | 2,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,851 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.

Mar 18 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

Mar 18 '07 #2

P: n/a
On 18 Mar, 21:00, "kwikius" <a...@servocomm.freeserve.co.ukwrote:
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();
//###############
Mar 18 '07 #3

P: n/a
On Mar 18, 5:01 pm, "kwikius" <a...@servocomm.freeserve.co.ukwrote:
On 18 Mar, 21:00, "kwikius" <a...@servocomm.freeserve.co.ukwrote:
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<intconst &)" (??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
Mar 18 '07 #4

P: n/a
And I did fix:
osObject<<current-<info<<" ";
to:
osObject<<current->info<<" ";

Already
Mar 18 '07 #5

P: n/a
On Mar 18, 5:48 pm, t...@weismannwebservices.com wrote:
On Mar 18, 5:01 pm, "kwikius" <a...@servocomm.freeserve.co.ukwrote:
On 18 Mar, 21:00, "kwikius" <a...@servocomm.freeserve.co.ukwrote:
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<intconst &)" (??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 BaseDatafriend ostream & operator<<(ostream&, const
linklist<BaseData>&);
and that fixed it.

Mar 19 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.