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

T

todd

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.
 
K

kwikius

On 18 Mar, 20:45, (e-mail address removed) 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
 
K

kwikius

On 18 Mar, 20:45, (e-mail address removed) wrote:



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

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

public:
 
T

todd

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

public:



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 said:
&,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
 
T

todd

And I did fix:
osObject<<current-<info<<" ";
to:
osObject<<current->info<<" ";

Already
 
T

todd

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top