delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/07/13:36:35

From: "Anthony.Appleyard" <MCLSSAA2 AT fs2 DOT mt DOT umist DOT ac DOT uk>
Organization: Materials Science Centre
To: DJGPP AT DELORIE DOT COM
Date: Mon, 7 Apr 1997 12:30:05 GMT-1
Subject: funny re user-defined ++ and -- operators
Reply-to: Anthony DOT Appleyard AT umist DOT ac DOT uk
Message-ID: <4C4D410EC4@fs2.mt.umist.ac.uk>

  This djgpp c++ test program:-

class cat{public: int kittens,micecaught;
void operator++();
void operator--();};
/*-----*/
void cat::operator++(){kittens=kittens+1;}
void cat::operator--(){kittens=kittens-1;}
main(){
cat Tabbins;
Tabbins++;
Tabbins--;
++Tabbins;
--Tabbins;}

  caused these warnings when compiled with -Wall:-

t$.cc: In function `int main()':
t$.cc:9: warning: no `operator++ (int)' declared for postfix `++', using
  prefix operator instead
t$.cc:9: warning: no `operator++ (int)' declared for postfix `++', using
  prefix operator instead
t$.cc:10: warning: no `operator++ (int)' declared for postfix `++', using
  prefix operator instead
t$.cc:10: warning: no `operator++ (int)' declared for postfix `++', using
  prefix operator instead

  (1) Line 10 used `--', but the warning re line 10 said `++'.
  (2) Do these warnings now mean that now I can declare distinct postfix and
prefix ++ and -- operators to use with classes? If so, how?

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019