fork download
  1. void draw_hex(double x_center, double y_center, double R, CDC* pDC) {
  2. static const double PI = 3.14159;
  3.  
  4. double C = R * cos(PI / 6);
  5. double S = R * sin(PI / 6);
  6.  
  7. pDC->MoveTo(x_center, y_center - R);
  8. pDC->LineTo(x_center + C, y_center - S);
  9. pDC->LineTo(x_center + C, y_center + S);
  10. pDC->LineTo(x_center, y_center + R);
  11. pDC->LineTo(x_center - C, y_center + S);
  12. pDC->LineTo(x_center - C, y_center - S);
  13. pDC->LineTo(x_center, y_center - R);
  14. }
  15.  
  16. /* ... */
  17.  
  18. static double PI = 3.1416;
  19.  
  20. static double R = 50;
  21. static const int left = 50;
  22. static const int top = 50;
  23. double x = 100.0;
  24. double y = 100.0;
  25.  
  26. for (int i = 0; i < 5; i++) {
  27. for (int j = 0; j < 5; j++) {
  28. double offset = R * cos(PI / 6);
  29. double x = left + i * 2 * offset + (j&1)*offset;
  30. double y = top + j * R * 3 / 2;
  31. draw_hex(x, y, R, pDC);
  32. }
  33. }
  34.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:59: error: ‘CDC’ has not been declared
 void draw_hex(double x_center, double y_center, double R, CDC* pDC) {
                                                           ^
prog.cpp: In function ‘void draw_hex(double, double, double, int*)’:
prog.cpp:4:27: error: ‘cos’ was not declared in this scope
  double C = R * cos(PI / 6);
                           ^
prog.cpp:5:27: error: ‘sin’ was not declared in this scope
  double S = R * sin(PI / 6);
                           ^
prog.cpp:7:7: error: request for member ‘MoveTo’ in ‘* pDC’, which is of non-class type ‘int’
  pDC->MoveTo(x_center, y_center - R);
       ^
prog.cpp:8:7: error: request for member ‘LineTo’ in ‘* pDC’, which is of non-class type ‘int’
  pDC->LineTo(x_center + C, y_center - S);
       ^
prog.cpp:9:7: error: request for member ‘LineTo’ in ‘* pDC’, which is of non-class type ‘int’
  pDC->LineTo(x_center + C, y_center + S);
       ^
prog.cpp:10:7: error: request for member ‘LineTo’ in ‘* pDC’, which is of non-class type ‘int’
  pDC->LineTo(x_center, y_center + R);
       ^
prog.cpp:11:7: error: request for member ‘LineTo’ in ‘* pDC’, which is of non-class type ‘int’
  pDC->LineTo(x_center - C, y_center + S);
       ^
prog.cpp:12:7: error: request for member ‘LineTo’ in ‘* pDC’, which is of non-class type ‘int’
  pDC->LineTo(x_center - C, y_center - S);
       ^
prog.cpp:13:7: error: request for member ‘LineTo’ in ‘* pDC’, which is of non-class type ‘int’
  pDC->LineTo(x_center, y_center - R);
       ^
prog.cpp: At global scope:
prog.cpp:26:2: error: expected unqualified-id before ‘for’
  for (int i = 0; i < 5; i++) {
  ^
prog.cpp:26:18: error: ‘i’ does not name a type
  for (int i = 0; i < 5; i++) {
                  ^
prog.cpp:26:25: error: ‘i’ does not name a type
  for (int i = 0; i < 5; i++) {
                         ^
prog.cpp:18:16: warning: ‘PI’ defined but not used [-Wunused-variable]
  static double PI = 3.1416;
                ^
prog.cpp:20:16: warning: ‘R’ defined but not used [-Wunused-variable]
  static double R = 50;
                ^
stdout
Standard output is empty