Connecting Tech Pros Worldwide Forums | Help | Site Map

template and friend problem

Rolf Wester
Guest
 
Posts: n/a
#1: Jul 19 '05
Hi,

I have some problems with fried declarations in a template class.
The class looks like:

namespace iltVector3
{

template<class T> class Matrix3
{
private:
T m_Mat[3][3];
int m_N;
public:
..
..
..

friend Matrix3<T> operator*(T a, Matrix3<T> & A);
};
}

When compiling with MSVC++6 I get an error message. The error message is
in German, so I try to translate:


f:\pr1\rt3d\src\cpp\ilt_vector3.h(197) : error C2143: Syntax error :
missing ';' ahead of '<'
f:\pr1\rt3d\src\cpp\ilt_vector3.h(199) : See reference to
instantiation of the precompiled class template 'iltVector3::Matrix3<T>'

Line 197 is exactly the line of the friend declaration.

Is my friend declaration wrong? Is it a bug (feature?) of VC++6?
I would be very appreciative for any help.

Regards

Rolf Wester


Christoph Rabel
Guest
 
Posts: n/a
#2: Jul 19 '05

re: template and friend problem


Rolf Wester wrote:[color=blue]
> When compiling with MSVC++6 I get an error message. The error message is
> in German, so I try to translate:
>
> f:\pr1\rt3d\src\cpp\ilt_vector3.h(197) : error C2143: Syntax error :
> missing ';' ahead of '<'
> f:\pr1\rt3d\src\cpp\ilt_vector3.h(199) : See reference to
> instantiation of the precompiled class template 'iltVector3::Matrix3<T>'
>
> Line 197 is exactly the line of the friend declaration.
>
> Is my friend declaration wrong? Is it a bug (feature?) of VC++6?
> I would be very appreciative for any help.[/color]

Your code is ok and the snipped compiles fine with VC6. Please post a
minimal example that shows your problem.

Christoph

John Harrison
Guest
 
Posts: n/a
#3: Jul 19 '05

re: template and friend problem



"Christoph Rabel" <odie@hal9000.vc-graz.ac.at> wrote in message
news:3f39fd56$1@e-post.inode.at...[color=blue]
> Rolf Wester wrote:[color=green]
> > When compiling with MSVC++6 I get an error message. The error message[/color][/color]
is[color=blue][color=green]
> > in German, so I try to translate:
> >
> > f:\pr1\rt3d\src\cpp\ilt_vector3.h(197) : error C2143: Syntax error :
> > missing ';' ahead of '<'
> > f:\pr1\rt3d\src\cpp\ilt_vector3.h(199) : See reference to
> > instantiation of the precompiled class template 'iltVector3::Matrix3<T>'
> >
> > Line 197 is exactly the line of the friend declaration.
> >
> > Is my friend declaration wrong? Is it a bug (feature?) of VC++6?
> > I would be very appreciative for any help.[/color]
>
> Your code is ok and the snipped compiles fine with VC6. Please post a
> minimal example that shows your problem.
>
> Christoph
>[/color]

Could be a service pack issue, the OP should make sure they have the latest
service pack (service pack 5 I think).

john


Rolf Wester
Guest
 
Posts: n/a
#4: Jul 19 '05

re: template and friend problem


Christoph Rabel wrote:[color=blue]
>
> Your code is ok and the snipped compiles fine with VC6. Please post a
> minimal example that shows your problem.
>
> Christoph
>[/color]
Christoph and Jogn thanks a lot for your replies. I don't know what is
different since when I got the posted error message but now it works
fine for me too. Sorry for the inconvenience.

Regards

Rolf Wester

Closed Thread