home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 15930 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.4 KB  |  42 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!pipex!warwick!bham!bhamvx!mccauleyba
  3. From: mccauleyba@vax1.bham.ac.uk (Brian McCauley)
  4. Subject: Re: Declaration Syntax Error
  5. Sender: usenet@rs6000.bham.ac.uk (USENET News Service)
  6. Message-ID: <1992Nov8.100412.1@vax1.bham.ac.uk>
  7. Date: Sun, 8 Nov 1992 10:04:12 GMT
  8. Lines: 30
  9. References: <trumpet-user.1.721149008@csc.cuhk.hk>
  10. Organization: University of Birmingham
  11.  
  12. In article <trumpet-user.1.721149008@csc.cuhk.hk>, trumpet-user@csc.cuhk.hk (Default Trumpet User) writes:
  13. > Could someone tell me why I got the captioned error message once I declared 
  14. > the following function:
  15. > int (*abcd) (int i)
  16. > { 
  17. >     ...
  18. > }
  19. Yes because abcd is not a function, it's a pointer to a function and you're not
  20. allowed to initialise a pointer to a function to an anonymous function in C++.
  21.  
  22. What you meant is either :
  23.   static int anon_func (int i) { ... }
  24.   int (*abcd) (int i) = anon_func;
  25. which makes abcd point to a static function which is the nearest thing you get
  26. to an anonymous function in C++
  27.  
  28. Or more likely:
  29.   int *abcd(int i) {...}
  30. which makes abcd a function returning a pointer to an integer
  31.  
  32. Please mail me as I'm not sure that my postings are gettimg out of our news
  33. server.
  34.      
  35.     \\   ( )  NO BULLSHIT! from BAM (Brian McCauley)
  36.  .  _\\__[oo 
  37. .__/  \\ /\@  E-mail: B.A.McCauley@bham.ac.uk
  38. .  l___\\        Fax: +44 21 625 2175
  39.  # ll  l\\     Snail: 197 Harborne Lane, Birmingham, B29 6SS, UK
  40. ###LL  LL\\     ICBM: 52.5N 1.9W
  41.