Advertisement
Xeeynamo

const error gcc

Dec 29th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Size
  5. {
  6.     int m_width;
  7.     int m_height;
  8. public:
  9.     Size(int width, int height) : m_width(width), m_height(height)
  10.     {
  11.  
  12.     }
  13.     int getWidth() const
  14.     {
  15.         return m_width;
  16.     }
  17.     int getHeight() const
  18.     {
  19.         return m_height;
  20.     }
  21. };
  22.  
  23. void PrintSize(/*const*/ Size& size) // WORKS IF PARAM IS CONST. NOT A PROBLEM WITH MVCPP
  24. {
  25.     cout << "Size: " << size.getWidth() << "x" << size.getHeight() << endl;
  26. }
  27.  
  28. int main()
  29. {
  30.     Size size(16, 9);
  31.     PrintSize(size);
  32.     PrintSize(Size(80, 50));
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement