8sa1-gcc/gcc/testsuite/g++.old-deja/g++.brendan/template11.C
Jeff Law 921e5a0eb4 Initial revision
From-SVN: r14840
1997-08-19 01:34:40 -06:00

48 lines
699 B
C

// Build don't link:
// GROUPS passed templates
template <class Called>
class aCallback
{
public:
aCallback(Called& obj, int (Called::*met)());
int callback();
protected:
private:
// the object to call
Called& object;
// the method to apply
int (Called::*method)();
};
template <class Called>
aCallback<Called>::aCallback(Called& obj,
int (Called::*met)()) :
object(obj),
method(met)
{};
template <class Called>
int aCallback<Called>::callback()
{
return (object.*method)();
}
struct myStruct
{
int action() {return 24;};
};
main()
{
myStruct toto;
aCallback<myStruct> cb(toto, &myStruct::action);
return cb.callback();
}