NickAndNick

C/C++ equal vs ==

May 13th, 2016
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. // Решение для C
  3. #define equal(a, b) ((a) == (b))
  4. // Решение для C++
  5. template<typename T> bool Equal(T a, T b) { return a == b; }
  6. int main() {
  7.     int a, b;
  8.     a = b = 5;
  9.     if (equal(a, b)) printf("Yes!\n");
  10.     else printf("No!\n");
  11.     if (Equal(a, b)) std::cout << "Yes!\n";
  12.     else std::cout << "No!\n";
  13.     std::cin.get();
  14. }
RAW Paste Data