G
gary.bernstein
Any idea why line 57 fails? http://rafb.net/p/86JdGg61.html
gs = MyShutdown<Component, T1, T2, T3>(this);
Errors:
shutdown1.cpp: In constructor `Component<T1, T2, T3>::Component(int)':
shutdown1.cpp:46: error: type/value mismatch at argument 1 in template
parameter list for `template<template<class T1, class T2, class T3>
class Calling_Comp
onent, class T1, class T2, class T3> class MyShutdown'
shutdown1.cpp:46: error: expected a class template, got
`Component<T1, T2, T3>'
#include <iostream>
#include <string>
using namespace std;
class Shutdown
{
virtual void begin()
{
cout << "shutdown" << endl;
exit(0);
}
};
Shutdown *gs;
template <template <class T1, class T2, class T3> class
Calling_Component, class T1, class T2, class T3>
class MyShutdown : public Shutdown
{
typedef Calling_Component<T1, T2, T3> Caller;
Caller& mCaller;
public:
MyShutdown(Caller& rCaller)
: mCaller(rCaller)
{
}
void begin()
{
cout << "MyShutdown caller # " << mCaller.mnId << endl;
exit(0);
}
};
template <typename T1, typename T2, typename T3>
class Component
{
public:
Component(int n)
: mnId(n)
{
gs = MyShutdown<Component, T1, T2, T3>(this);
}
int mnId;
};
int main()
{
Component<int, int, string> c(5);
MyShutdown<Component, int, int, string> s(c);
s.begin();
}
gs = MyShutdown<Component, T1, T2, T3>(this);
Errors:
shutdown1.cpp: In constructor `Component<T1, T2, T3>::Component(int)':
shutdown1.cpp:46: error: type/value mismatch at argument 1 in template
parameter list for `template<template<class T1, class T2, class T3>
class Calling_Comp
onent, class T1, class T2, class T3> class MyShutdown'
shutdown1.cpp:46: error: expected a class template, got
`Component<T1, T2, T3>'
#include <iostream>
#include <string>
using namespace std;
class Shutdown
{
virtual void begin()
{
cout << "shutdown" << endl;
exit(0);
}
};
Shutdown *gs;
template <template <class T1, class T2, class T3> class
Calling_Component, class T1, class T2, class T3>
class MyShutdown : public Shutdown
{
typedef Calling_Component<T1, T2, T3> Caller;
Caller& mCaller;
public:
MyShutdown(Caller& rCaller)
: mCaller(rCaller)
{
}
void begin()
{
cout << "MyShutdown caller # " << mCaller.mnId << endl;
exit(0);
}
};
template <typename T1, typename T2, typename T3>
class Component
{
public:
Component(int n)
: mnId(n)
{
gs = MyShutdown<Component, T1, T2, T3>(this);
}
int mnId;
};
int main()
{
Component<int, int, string> c(5);
MyShutdown<Component, int, int, string> s(c);
s.begin();
}