Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <vector>
- #define fp32 float
- #define u32 unsigned int
- class BV
- {
- public:
- BV(fp32 x, fp32 y)
- : _x(x)
- , _y(y)
- {
- }
- public:
- fp32 _x;
- fp32 _y;
- };
- std::pair<u32, BV&> GetValue(std::vector<BV>& values, u32 index)
- {
- return std::make_pair(index, values[index]);
- }
- void TestAll()
- {
- std::vector<BV> values;
- values.push_back(BV(0.0, 0.0));
- values.push_back(BV(2.0, 0.0));
- values.push_back(BV(3.0, 0.0));
- std::pair<u32, BV&> pair1 = GetValue(values, 0);
- BV& val1 = GetValue(values, 0).second;
- //BV& val1 = pair1.second;
- fp32 a = val1._x + 1.0f;
- std::pair<u32, BV&> pair2 = GetValue(values, 0);
- BV& val2 = GetValue(values, 2).second;
- //BV& val2 = pair1.second;
- fp32 b = val2._x + 1.0f;
- printf("val1 x = %f; y = %f;\n", val1._x, val1._y);
- printf("val2 x = %f; y = %f;\n", val2._x, val2._y);
- fp32 c = val1._x + 1.0f;
- printf("val1 x = %f; y = %f;\n", val1._x, val1._y);
- printf("val2 x = %f; y = %f;\n", val2._x, val2._y);
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- TestAll();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement