Can anyone please tell me whats wrong with this code, why is it not executing???
My Compiler says:
Error: Unresolved external 'List<int>::List<int>(List<int>&)' referrenced from h:\data structures\myfile.obj
and if i remove comments from the commented part then i get like almost 6 more errors, can anyone please please help me out on this.............
[syntax="cpp"]
#include<iostream>
using namespace std;
template<class T>
class List{
protected:
struct Node
{
T _data;
Node *_next;
Node(T data = T(), Node* next = NULL):
_data(data),_next(next) { }
};
Node *Head, *Current;
List ( List & value );
public:
List():Head(new Node),Current(Head)
{ }
List( const List& );
void insert( const T& value )
{
Node* P = new Node( value , Current->_next );
if( P == NULL )
std::cerr << "Out of Space";
else
{
Current->_next = P;
Current = Current->_next;
}
}
void First( )
{
if( Head->_next != NULL )
Current = Head->_next;
}
int operator !() const
{
return Current != NULL;
}
List operator ++()
{
if( Current != NULL )
Current = Current->_next;
return *this;
}
T & operator ( ) ( ) const
{
if( Current != NULL )
return Current->_data;
else
return Head->_data;
}
/*
***********Problematic code**************
const List opeator = ( List & value )
{
for ( value.First( ); !value; value++ )
{
Current->_next = new Node( Value( ) , Curent->_next );
Current = Current->_next;
}
Current->_next = 0;
First();
value.First();
return *this;
}*/
int isEmpty() const { return Head->_next == NULL;}
};
template<class T>
void Print ( List<T> &L )
{
if( L.isEmpty() == NULL )
cout << "Empty List";
else
for( L.First(); !L; ++L )
cout << L( ) << ends;
}
int main()
{
List<int> b;
b.insert(5);
Print(b);
return 0;
}
[/syntax]
