| |
comp.lang.c++.moderated |
Hi all. Here's a little quandry I've run in to and can't tell if it's a compiler =================================== template < typename T > public: B( ) { } class N1 public: N1( ) { }; class N2 public: N2( ) { }; virtual void f( ) }; }; T _m; public: class N1 : public B< int >::N1 public: N1( ) : B< int >::N1( ) { }; class N2 : public B< int >::N1::N2 public: N2( ) : B< int >::N1::N2( ) { }; virtual void f( ) }; }; n2.f( ); Invoking n2.f( ) causes an infinite loop, dumping out "D::N1::N2::f( )" What am I doning wrong? How can I call the base's f( )? Thanks for any help you can offer! - Roger [ See http://www.gotw.ca/resources/clcm.htm for info about ]
bug, or if it's bad code. First, here's the code:
#include <stdio.h>
class B
{
{
{
{
printf( " B< >::N1::N2::f( )\n" );
}
{
{
{
{
printf( " D::N1::N2::f( )\n" );
( ( B< int >::N1::N2* ) this )->f( );
}
main( int argc, char* argv[ ] )
{
D::N1::N2 n2;
ad-nausium. I am trying to call the base-class f( ) in B::N1::N2, but the
compiler just generates code that instead calls D::N1::N2::f( ) recursively.
[ comp.lang.c++.moderated. First time posters: Do this! ]