Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #8562
| From | jt@toerring.de (Jens Thoms Toerring) |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: help on constructor/constructor initialization list with inheritance using templates |
| Date | 2011-08-08 09:46 +0000 |
| Organization | Freie Universitaet Berlin |
| Message-ID | <9a9pkfFft8U1@mid.uni-berlin.de> (permalink) |
| References | <9086d735-ed4d-4943-9d01-40f3d0f726b5@l11g2000prh.googlegroups.com> |
balaji <kasthurirangan.balaji@gmail.com> wrote:
> Hi,
> Pls find below the sample code.
> File 1
> template< class A, template < typename > class B >
> class C : public B<A>
> {
> public:
> explicit C(const char *msg);
> ~C();
> private:
> //copy constructor and assignment operator
> }
You're missing a semicolon here (and also is some other
places at the end of declarations of classes).
> template< class A, template < typename > class B >
> C<A, B> :: C(const char *msg)
> : B(msg)
This is the place my compiler doesn't like when other,
minor issues are fixed:
error: no matching function for call to ‘B<A>::B()’
note: candidates are: B<Z>::B(const char*) [with Z = A]
note: B<A>::B(const B<A>&)
Shouldn't that be
template< class A, template < typename > class B >
C< A, B > :: C( const char * msg )
: B< A >( msg )
since B<A> is the base class C is derived from?
Otherwise I guess the compiler will try to invoke the
default constructor of B<A> (since there's no explicit
call of it - you call B(msg), not B<A>(msg)) and since
there is none it gives up.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
help on constructor/constructor initialization list with inheritance using templates balaji <kasthurirangan.balaji@gmail.com> - 2011-08-08 02:00 -0700
Re: help on constructor/constructor initialization list with inheritance using templates jt@toerring.de (Jens Thoms Toerring) - 2011-08-08 09:46 +0000
Re: help on constructor/constructor initialization list with inheritance using templates balaji <kasthurirangan.balaji@gmail.com> - 2011-08-10 04:01 -0700
Re: help on constructor/constructor initialization list with inheritance using templates jt@toerring.de (Jens Thoms Toerring) - 2011-08-10 12:06 +0000
csiph-web