[MUD-Dev] [TECHNICAL] [SOLVED] (template problem).

Ben Greear greear at cyberhighway.net
Mon May 31 16:29:03 CEST 1999


bruce at puremagic.com wrote:
> Templates with g++ 2.7.2 are so much fun.
> 
> > So the question is, anyone know how to get the compiler to spit out the
> > pre-processed code so I can take a look at what line it's complaining about?
> 
> gcc -E will send the preprocessed output to stdout and not try to compile
> it.

That worked, but produced nothing that I knew how to make use of,
however...

> 
> For the mangled symbol, check out the program c++filt .. it is really
> useful.

That provided the clue I needed!! 
(It was the: ObjArray<int>& operator=(const ObjArray<int> blah); method.

The problem was something like this:

#include "MyTemplate.h"

class foo {
	ObjArray<int> array;
	foo(const foo& src) { *this = src; }
	...
	// The important part is that no operator=(const foo& src) is defined
};


It looks like when g++ 2.7.2 was creating the default operator= method, it did
not count that as a reason to instantiate/create/whatever the ObjArray<T>
operator= method. (Which was defined and implemented.)

After I put the operator= in class foo (which just did a this->blah = src.blah
for all members blah), it compiled and linked fine (and is now running :))

Thanks for all the help folks!

Ben

--
Ben Greear (greear at cyberhighway.net)  http://www.primenet.com/~greear 
Author of ScryMUD:  mud.primenet.com 4444        (Released under GPL)
http://www.primenet.com/~greear/ScryMUD/scry.html


_______________________________________________
MUD-Dev maillist  -  MUD-Dev at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev




More information about the mud-dev-archive mailing list