Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!uc!cs.umn.edu!ux.acs!hopper From: hopper@ux.acs.umn.edu (hopper) Newsgroups: comp.lang.c++ Subject: Re: Turbo-C++ catch, template, .* , ->* Message-ID: <2151@ux.acs.umn.edu> Date: 28 Aug 90 21:46:23 GMT References: Reply-To: hopper@ux.acs.umn.edu (Eric Hopper) Distribution: comp Organization: Omnifarious Software Lines: 69 In article ahuttune@niksula.hut.fi (Ari Juhani Huttunen) writes: > >I found something strange in TC++ documentation recently. The keywords >and operatators mentioned in the header of this article are mentioned >in "Turbo C++ Programmer's Guide", but NOWHERE is there any explanation >for them.. At least I couldn't find any. > >So, what are operators > .* > ->* >and keywords > catch > template I've never heard of those keywords, but the operators are documented in the Turbo C++ online manual. They may be in the paper manual too, but I don't look at that a lot. It doesn't provide a complete enough definition for me. The operators .* and ->* are pointer-to-member referencing operators. C++ has provided a way to get offset pointers into a class, the best way to explain it is an example. (Note: This was gotten from 'Programming In C++' by Stephen C. Dewhurst & Kathy T. Stark, part of the Prentice Hall Software Series, a book I kinda like.) class Node { public: int code; int num; void print(); void report(); }; SomeSillyFunction(Node &n, int Node::*pi) { *np = &n; int i, j; i = n.*pi; j = np->*pi; } main() { Node n; SomeSillyFunction(n, &(Node::num)); // Both i & j get set to n.num SomeSillyFunction(n, &(Node::code)); // Both i & j get set to n.code } I presume that this construct would be most useful when offset pointers to functions. It is the only reliable way to get the address of a member function, since they have to have a this pointer passed to them. Have fun, UUCP: rutgers!umn-cs!ux.acs.umn.edu!hopper (Eric Hopper) __ /) /**********************/ / ') // * I went insane to * / / ______ ____ o // __. __ o ____. . _ * preserve my sanity * (__/ / / / <_/ / <_<__//__(_/|_/ (_<_(_) (_/_/_)_ * for later. * Internet: /> * -- Ford Prefect * hopper@ux.acs.umn.edu /**********************/ -- -- Nils_McCarthy mtymp01@ux.acs.umn.edu rutgers!umn-cs!ux.acs.umn.edu!mtymp01 "The wonders of modern technology..." :-) :-) :-)