Hi,
Thank you for helping and here is the problem:

#include <string>
#include <fstream>
#include <vector>
#include <iostream>
using std::string;
using std::ifstream;
template<class t>
class Openfile
{
private:
	string pavadinimas;
	ifstream fin;
public:
	typedef ifstream & reference; 
	Openfile();
	Openfile(const char * c);
	reference rout();
	std::vector<t> & operator>>(std::vector<t> &);
	~Openfile();
};

I 'm getting problem when I trying to define the ruot() function and here is the definition:

template<class t>
Openfile<t>::reference Openfile<t>::rout()
{
	return fin;
}

When I change the t to string type argument th problem goes away.
My compiler say the I' am missing destructor, constructor before Openfile...

It is another one of these typename instances.

First off the solution is this:

template<class t>
typename Openfile<t>::reference Openfile<t>::rout()
{
  return fin;
}

Ok that is the simple part, now I am going to make a complete mess of trying to explain WHY you need a typename. [sorry in advance].

The compile at this point when it sees somthing like this:

template<typename T> 
A<T>::X A<T>::Y() { }

Now what does that mean? It could be a method definition as you wish it to be OR it could be a constructor e.g. a complex form of

template<typename T>
class A 
{ 
   class X {};
};

A<T>::X object();

Now to avoid this ambiguity, you have to add typename. Note EVEN if you have the whole class there in the definition, this still holds. The basic rule is if you are using a template in a object type that is NOT a instance declaration then you need a typename.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.