Hello Jerry, I tried this and It worked for me on g++ (3.4.4). #include<list> using namespace std; std::list<class P*> P; /*I tried for list template, it should work for pair also*/ typedef class P* Y; typdef std::list<Y> P_new; /*P_new is the class what u are expecting.*/ HTH, Vamsi kundeti On 8/24/05, John D Lamb <J.D.Lamb@btinternet.com> wrote:
Jerry Feldman wrote:
On Sunday 21 August 2005 3:51 pm, John D Lamb wrote:
Here's a puzzle: I'd like to define something like
typedef std::pair<int,P*> P;
I can obviously do
class P : public std::pair<int,P*>{};
or
typedef std::pair<int,void*> P; In this case, you have not yet defined P. You could use a forward declaration, such as: class P; Then, typedef std::pair<int,P*> P; should work. I have not tried your example specifically.
Sadly it doesn't work though I actually had to try this to see. It does confirm that I'm not being totally stupid in thinking that C++ might reasonably allow this sort of thing.
The C++ standard doesn't allow you to use typedef for a name already declared in the same scope.
I think C++ won't allow you to do something like:
class X<X*> x;
i.e. create a template class whose template parameter is a pointer to an object of this class. It will allow
class Y : public class X<Y*> {} x;
which is nearly the same.
For my own problem, I've worked out I can use static_cast rather than reinterpret_cast, which is a bit of an improvement.
-- JDL
-- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists.suse.com/archive/suse-programming-e