Re: templating



I think that you need create a third class, as:

class tClassEmpty : tClass {
    tClassEmpty() : tClass("") { .. };
    ...
}

class myNodeClass : NodeTree<tClassEmpty> {
...

2008/12/21 Robert Rehammar <robert rehammar se>
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
http://mail.gnome.org/mailman/listinfo/gtkmm-list



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