Re: How to make templated operator= more specific?
Thank you very much for answers.
It was tipo about Foo<int> fi;, i meant something like Foo fi(4);
The point was to develop exactly not templated class Foo.
so the question still open we have class Foo like:
class Foo {
public:
template<typename T>
Foo(T f) { bb = new Bar<T>(f); }
template<typename T> operator Bar<T>() {
return static_cast<Bar<T>&>(*bb);
}
private:
BarBase *bb;
};
now I can rephrase question:
When I declare Foo with some parameter, e.g.
Foo fi(42);
we instantiate templated Foo's contructor with type int.
How can I define exactly one conversion operator with type Bar<int>,
still having non-templated class Foo? Is it possible at all?
More precisely i'd like to save type with which constructor was
instantiated.
I thought about typedef inside constructor, but
it's scope limited to constructor.
I know, the question is quite strange, but non-templated class Foo
leads me to beautifull design and it's handy using.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]