Re: class matrix
<wojtas.wtk@gmail.com> wrote in message
news:1148207720.453245.140160@i40g2000cwc.googlegroups.com
The code contains quite a lot of errors(...)
I use Microsoft Visual C++ and I see only two error:
a.obj : error LNK2001: unresolved external symbol "class
std::basic_ostream<char,struct std::char_traits<char> > & __cdecl
operator<<(class std::basic_ostream<char,struct std::char_traits<char>
,class matrix2x2)" (??6@YAAAV?$basic_ostream@DU?$char_
traits@D@std@@@std@@V01@Vmatrix2x2@@@Z)
Debug/a.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
I only see one, and one is all it takes.
I ran your code on three different versions of VC++ and got three different
sets of errors. Judging by your errors, you are using VC++ 6, which predates
the current standard and should not be used for anything except the
maintenance of old applications.
You can find a free version of Microsoft's current compiler here:
http://msdn.microsoft.com/vstudio/express/visualc/
In any event, the problem with your code is that you have declared the
friend operator << but not defined it. You also should change the signature
of that friend to:
friend ostream &operator << (ostream & os, const matrix2x2 & X);
i.e., make both arguments references along with the return type (the
reference for the ostream argument is essential; the reference for the
matrix2x2 is merely preferable).
--
John Carson