fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <array>
  4.  
  5. using namespace std;
  6.  
  7. class Vertex
  8. {
  9. public:
  10. Vertex( float x = 0,
  11. float y = 0,
  12. float z = 0)
  13. : x(x), y(y), z(z) {}
  14.  
  15. operator array<float, 3>() {
  16. return array<float, 3>({x,y,z});
  17. }
  18. void fillArray(float (& const arr)[3]) {
  19. arr[0] = x;
  20. arr[1] = y;
  21. arr[2] = z;
  22. }
  23.  
  24. float x, y, z;
  25. };
  26.  
  27. int main() {
  28. Vertex v(1,1.4,2);
  29. array<float, 3> arr = v;
  30. float arr2[3];
  31. v.fillArray(arr2);
  32.  
  33. for (int i = 0; i < 3; i++) {
  34. cout << arr[i] << " " << arr2[i] << endl;
  35. }
  36. return 0;
  37. }
Compilation error #stdin compilation error #stdout 0s 3412KB
stdin
Standard input is empty
compilation info
prog.cpp:18:39: error: 'const' qualifiers cannot be applied to 'float (&)[3]'
  void fillArray(float (& const  arr)[3]) {
                                       ^
stdout
Standard output is empty