B
balaji
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
}
template< class A, template < typename > class B >
C<A, B> :: C(const char *msg)
: B(msg)
{
}
template< class A, template < typename > class B >
C<A, B> :: ~C()
{
}
File 2
template < class Z>
class B : public Z
{
public:
explicit B(const char *msg);
~B();
private:
//copy constructor and assignment operator
}
template < class Z>
B<Z> :: B(const char *msg)
: Z(msg)
{
}
template < class Z>
B<Z>::~B()
{
}
File 3
3.h
class A
{
public:
explicit A(const char *msg);
~A();
private:
//copy constructor and assignment operator
}
3.C
#include "3.h"
A::A(const char *msg)
{
}
A::~A()
{
}
main file
#iinclude file 1, file 2 and file 3(.h)
int
main(int argc, char **argv)
{
C<A,B> objc("Success");
return 0;
}
when i compile this code, i get the following error "The base class
"B<A>" cannot be initialized because it does not have a default
constructor.". I do not understand what i have missed to get this
error. Pls help me to resolve this.
Thanks,
Balaji.
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
}
template< class A, template < typename > class B >
C<A, B> :: C(const char *msg)
: B(msg)
{
}
template< class A, template < typename > class B >
C<A, B> :: ~C()
{
}
File 2
template < class Z>
class B : public Z
{
public:
explicit B(const char *msg);
~B();
private:
//copy constructor and assignment operator
}
template < class Z>
B<Z> :: B(const char *msg)
: Z(msg)
{
}
template < class Z>
B<Z>::~B()
{
}
File 3
3.h
class A
{
public:
explicit A(const char *msg);
~A();
private:
//copy constructor and assignment operator
}
3.C
#include "3.h"
A::A(const char *msg)
{
}
A::~A()
{
}
main file
#iinclude file 1, file 2 and file 3(.h)
int
main(int argc, char **argv)
{
C<A,B> objc("Success");
return 0;
}
when i compile this code, i get the following error "The base class
"B<A>" cannot be initialized because it does not have a default
constructor.". I do not understand what i have missed to get this
error. Pls help me to resolve this.
Thanks,
Balaji.