fork download
  1. #include <iostream>
  2.  
  3. struct SVector
  4. {
  5. float X, Y, Z;
  6. };
  7.  
  8. class CVector
  9. {
  10. private:
  11. float X, Y, Z;
  12.  
  13. public:
  14. CVector(float X, float Y, float Z) : X(X), Y(Y), Z(Z) {}
  15.  
  16. void set(float X, float Y, float Z)
  17. {
  18. this->X = X; this->Y = Y; this->Z = Z;
  19. }
  20.  
  21. bool operator == (const CVector& V) const
  22. {
  23. return ((X == V.X) && (Y == V.Y) && (Z == V.Z));
  24. }
  25.  
  26. CVector& operator ^= (const CVector& V)
  27. {
  28. X = (Y * V.Z) - (Z * V.Y);
  29. Y = (Z * V.X) - (X * V.Z);
  30. Z = (X * V.Y) - (Y * V.X);
  31. return *this;
  32. }
  33.  
  34. CVector& CrossProduct(const CVector& V)
  35. {
  36. return CVector(*this) ^= V;
  37. }
  38. };
  39.  
  40.  
  41. void GLFunc(void* some_vertex_structure, int size, int stride)
  42. {
  43. for (int i = 0; i < size / stride; ++i)
  44. {
  45. unsigned char* c = reinterpret_cast<unsigned char*>(some_vertex_structure) + (stride * i);
  46. std::cout<<*reinterpret_cast<float*>(c)<<"\n";
  47. }
  48. }
  49.  
  50. int main()
  51. {
  52. SVector sv = {1.0f, 2.0f, 3.0f};
  53.  
  54. CVector cv(4.0f, 5.0f, 6.0f);
  55.  
  56. GLFunc(&sv, sizeof(sv), sizeof(float));
  57. GLFunc(&cv, sizeof(cv), sizeof(float));
  58. return 0;
  59. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
1
2
3
4
5
6