I get some compiling errors about template instantiation , but I can't find where the syntax errors happens. Can some help me?
Code:
template<typename Type> class SingleList;
template<typename Type> class SingleListNode{
private:
friend class SingleList<Type>;
SingleListNode() : next(NULL){}
public:
friend ostream& operator<< <Type>(ostream& os,SingleListNode<Type>& sln); //Error!!!
private:
SingleListNode *next;
};
template<typename Type> ostream& operator<<(ostream& os,SingleListNode<Type>& out){
os<<out.data;
return os;
}
template<typename Type> class SingleList{
public:
SingleList()
{
head = new SingleListNode<Type> () ; //Error!!!
}
~SingleList(){
delete head;
}
private:
SingleListNode<Type> *head;
};
Compiler error message:
Code:
|| g++ -g -I ./inc/ -c single_list_test.cpp -o single_list_test.o
|| single_list.h: In instantiation of ‘SingleListNode<int>’:
single_list.h|25 col 13| instantiated from ‘SingleList<Type>::SingleList() [with Type = int]’
single_list_test.cpp|9 col 18| instantiated from here
single_list.h|10 col 18| error: template-id ‘operator<< <int>’ for ‘std::ostream& operator<<(std::ostream&, SingleListNode<int>&)’ does not match any template declaration
|| make:
*** [single_list_test.o] Error 1
Hello Again,
I am just wanted to know if we can call the Template using "require_once" at PHP?
Any views around happy to discuss.
Thanks in Advance (2 Replies)
hi experts,
i'm trying to do this:
file1 is a template. might have kinds of 'funny' characters.
sample:
<body>
<form>
<p><input type="text" name="abc"/></p>
<p><my_content></p>
</form>
</body>
file2 is a file that contains lots of text. this might be very big. might have... (2 Replies)
Hi all,
Need your help. I am doing a simple template program , getting some error ... here is the code
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include<string>
#include <sstream>
using namespace std;
class Base_class
{
public:
Base_class(){... (1 Reply)
Hello.
I want to copy temp files when I make a new file by vi.
For example,
09:32:52 ~/ $ mkdir test
09:33:03 ~/ $ cd test/
09:33:09 ~/test/ $ ls
09:33:16 ~/test/ $ vi test.cpp
09:34:37 ~/test/ $ cat test.cpp
#include <iostream>
int main()
{
}
09:34:48 ~/test/ $ vi test.bash
09:35:19... (1 Reply)
Hi, i have class template,
1)can i override the copy constructor
2)can we have virtual function in class template
if not plz tel why? I tried , compile error comes for me...
Thanks
Sarwan (0 Replies)