function macro of get the max value number : define « Development « C++ Tutorial






#include <iostream>
using namespace std;

#define getmax(a,b) ((a)>(b)?(a):(b))

int main()
{
  int x=5, y;
  y= getmax(x,2);
  cout << y << endl;
  cout << getmax(7,x) << endl;
  return 0;
}








5.16.define
5.16.1.ASSERTS
5.16.2.function macro of get the max value number
5.16.3.Using parentheses in macros.
5.16.4.Using inline rather than a macro.
5.16.5.A simple assert() macro.
5.16.6.Printing values in DEBUG mode