Re: templating


ok, if I got your problem, you ran into the problem, that you can't pass
arguments to the template class, because the template class itself is a

You have to write a method wich forks the additional parameters like

myNodeClass<tClass> sometpl;
sometpl.push_back("parameter"); // where parameter is type string

So the constructor of tClass don't have parameters.

Just have a look at

There you can define wich type of template the vector should contain,
but the template data is later.

If I have missunderstood your problem, or I'm generally wrong, just
correct Me. :-)



Am Sonntag, den 21.12.2008, 08:52 +0100 schrieb Robert Rehammar:
> Hi all,
> I'm writing a small program and has bumped in to a problem. It is
> probably actually C++ related, but since it should be a problem lot's of
> people here face I'll ask here. I want to do the following:
> class tClass {
> 	tClass (string s) {...};
> 	...
> }
> class myNodeClass : NodeTree<tClass> {
> 	myNodeClass (string s) :
> 		NodeTree<tClass> {
> 		...
> 	};
> }
> But this won't compile as the template for NodeTree, tClass, requires a
> parameter (the string s) and I simply can't figure out how to pass it to
> the template.
> Writing the constructor as
> myNodeTree (string s): NodeTree<tClass (s)> won't compile, complaining
> that s can't appear in a constant expression, so this seem so suggest
> that I can't template with a class that require any parameters for
> initiation...
> Thanks in advance!
> \\Robert Rehammar
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]