"Trey Jackson" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > [...] > I was unable to get that to compile. > Linux gcc 3.2.1, or HP aCC: HP ANSI C++ B3910B X.03.32 > > The linux error gave me a syntax error before the '{' token on the lines > declaring 'insertCode' in both SubstituteHello and SubstituteGoodbye.
That's correct. > ,---------------- > | #include <iostream> > | > | using std::cout; using std::endl; > | > | template<class ToBeSubstituted> > | struct userClass { > | void function() { > | // code is inserted here, not a function call to a member of > | ToBeSubstituted::insertCode(); > | } > | }; > | > | struct SubstituteHello { > | typedef void fn(); > | > | static fn insertCode { > | cout << "hello world" << endl; > | } > | }; You can use a typedef to declare a function, but not to define one. This code should actually be: static void insertCode() { ... > | struct SubstituteGoodbye { > | typedef void fn(); > | > | static fn insertCode { > | cout << "goodbye world" << endl; > | } > | }; And here. > [...] > This compiles, runs with undesired behavior; > ,---------------- > | struct SubstituteHello { > | typedef void fn(); > | > | static void insertCode() > | { > | dummy d; > | cout << "Hello World" << endl; > | } That's pretty much how you have to do it. > | // typedef void fn(); > | // static fn insertCode { > | // cout << "hello world" << endl; > | // } > | }; > `---------------- > [...] Dave _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost