Advertisement
Guest User

Untitled

a guest
Nov 17th, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1.  
  2. #include "stdafx.h"
  3. #include <vector>
  4. #define fp32 float
  5. #define u32 unsigned int
  6. class BV
  7. {
  8. public:
  9.     BV(fp32 x, fp32 y)
  10.         : _x(x)
  11.         , _y(y)
  12.     {
  13.     }
  14.  
  15. public:
  16.     fp32 _x;
  17.     fp32 _y;
  18. };
  19. std::pair<u32, BV&> GetValue(std::vector<BV>& values, u32 index)
  20. {
  21.     return std::make_pair(index, values[index]);
  22. }
  23.  
  24. void TestAll()
  25. {
  26.     std::vector<BV> values;
  27.     values.push_back(BV(0.0, 0.0));
  28.     values.push_back(BV(2.0, 0.0));
  29.     values.push_back(BV(3.0, 0.0));
  30.     std::pair<u32, BV&> pair1 = GetValue(values, 0);
  31.     BV& val1 = GetValue(values, 0).second;
  32.     //BV& val1 = pair1.second;
  33.     fp32 a = val1._x + 1.0f;
  34.     std::pair<u32, BV&> pair2 = GetValue(values, 0);
  35.     BV& val2 = GetValue(values, 2).second;
  36.     //BV& val2 = pair1.second;
  37.     fp32 b = val2._x + 1.0f;
  38.     printf("val1 x = %f; y = %f;\n", val1._x, val1._y);
  39.     printf("val2 x = %f; y = %f;\n", val2._x, val2._y);
  40.     fp32 c = val1._x + 1.0f;
  41.     printf("val1 x = %f; y = %f;\n", val1._x, val1._y);
  42.     printf("val2 x = %f; y = %f;\n", val2._x, val2._y);
  43. }
  44. int _tmain(int argc, _TCHAR* argv[])
  45. {  
  46.     TestAll();
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement