W
W. Cerven
I am using the C++ STL container "list" to create a template nested
list. Attached are my basic code and compiler errors. Oddly enough,
I when I create a non-template version of this nested list, I do not
get this problem. Any help someone could provide would be great.
Thanks.
nestedlisttemplate.h:
----------------------------
using namespace std;
#ifndef _nestedlisttemplate_h
#define _nestedlisttemplate_h
#include<iostream>
#include<list>
template<typename Etype>
class NestedListTemplateublic list<Etype>{
public:
NestedListTemplate();
~NestedListTemplate();
friend ostream& operator<<(ostream & Out, NestedListTemplate&
llists);
private:
};
#endif
nestedlisttemplate.C:
-----------------------------
using namespace std;
#include "nestedlisttemplate.h"
#include<iostream>
#include<list>
template<typename Etype>
NestedListTemplate<Etype>::NestedListTemplate(){};
template<typename Etype>
NestedListTemplate<Etype>::~NestedListTemplate(){};
template<typename Etype>
ostream& operator<<(ostream & Out, NestedListTemplate<Etype>& llists){
Out<<"Test Complete \n";
return Out;
}
using namespace std;
#include "nestedlisttemplate.h"
#include<iostream>
#include<list>
int main()
{
cout<<"\nTesting Constructors ...\n";
NestedListTemplate<int> alist;
cout<<"\nTesting output operator ...\n";
cout<<alist<<"\n";
return 0;
};
compiler command and error:
----------------------------------------
CC -c nestedlisttemplate.C
CC test_nestedlist.C nestedlist.o nestedlisttemplate.o -o
test_nestedlist
Undefined first referenced
symbol in file
std:stream &operator<<(std:stream &,NestedListTemplate<int>&)
test_nestedlist.o
ld: fatal: Symbol referencing errors. No output written to
test_nestedlist
list. Attached are my basic code and compiler errors. Oddly enough,
I when I create a non-template version of this nested list, I do not
get this problem. Any help someone could provide would be great.
Thanks.
nestedlisttemplate.h:
----------------------------
using namespace std;
#ifndef _nestedlisttemplate_h
#define _nestedlisttemplate_h
#include<iostream>
#include<list>
template<typename Etype>
class NestedListTemplateublic list<Etype>{
public:
NestedListTemplate();
~NestedListTemplate();
friend ostream& operator<<(ostream & Out, NestedListTemplate&
llists);
private:
};
#endif
nestedlisttemplate.C:
-----------------------------
using namespace std;
#include "nestedlisttemplate.h"
#include<iostream>
#include<list>
template<typename Etype>
NestedListTemplate<Etype>::NestedListTemplate(){};
template<typename Etype>
NestedListTemplate<Etype>::~NestedListTemplate(){};
template<typename Etype>
ostream& operator<<(ostream & Out, NestedListTemplate<Etype>& llists){
Out<<"Test Complete \n";
return Out;
}
using namespace std;
#include "nestedlisttemplate.h"
#include<iostream>
#include<list>
int main()
{
cout<<"\nTesting Constructors ...\n";
NestedListTemplate<int> alist;
cout<<"\nTesting output operator ...\n";
cout<<alist<<"\n";
return 0;
};
compiler command and error:
----------------------------------------
CC -c nestedlisttemplate.C
CC test_nestedlist.C nestedlist.o nestedlisttemplate.o -o
test_nestedlist
Undefined first referenced
symbol in file
std:stream &operator<<(std:stream &,NestedListTemplate<int>&)
test_nestedlist.o
ld: fatal: Symbol referencing errors. No output written to
test_nestedlist