Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!pasteur!cory.Berkeley.EDU!achoi From: achoi@cory.Berkeley.EDU (Andrew Choi) Newsgroups: comp.lang.c++ Subject: How To Do User-Defined Conversion? Keywords: operator Message-ID: <28717@pasteur.Berkeley.EDU> Date: 12 Oct 90 02:24:44 GMT Sender: news@pasteur.Berkeley.EDU Reply-To: achoi@cory.Berkeley.EDU (Andrew Choi) Organization: University of California, Berkeley Lines: 31 Hello world. This may be a simple question to most of you, but I just cannot figure it out. How do you define the operator which converts a class object to a pointer to a function returning int? More specifically, I want to do the following: Class A; int (*fp)(); fp = A; /* Needs user-defined conversion here */ fp(); I tried the followings: operator int (*)() { ... } operator int (*)()() { ... } // I think it's either this operator (int (*)())() { ... } // or this operator int (*())() { ... } However, g++ version 1.37.2 alpha 2 gives me parse errors on all 4 approaches. Does anyone know how to do this correctly? Is it legal or possible to define an operator which does the above conversion. Thank you very much for your help. Name: Andrew Choi Internet Address: achoi@cory.berkeley.edu Tel: (415)848-5658 #include