Language: C++

   
//座標軸
    glBegin(GL_LINES);
    glVertex2d(-1,0);
    glVertex2d(1,0);
    glVertex2d(-1.5/2,1);
    glVertex2d(-1.5/2,-1);
    glEnd();

//文字
    PrintText(-0.8,0,"0");
    Print(-1,0.5,"0.0000001");
    Print(-1,-0.5,"0.0000001");
    PrintText(-0.25,0,"1");
    PrintText(0.25,0,"2");
    PrintText(0.75,0,"3");



void PrintText(double w,double h,char str[]){
  glRasterPos2d(w,h);
  for(int i=0;i< sizeof(str[i]);i++){
    glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,str[i]);
  }
}

void Print(double w ,double h , char str[]){
  glRasterPos2d(w,h);
  for(int i=0;i< 10;i++){
    glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,str[i]);
  }
}

Compiler output:
a.cc:3:12: error: expected constructor, destructor, or type conversion before '(' token
    3 |     glBegin(GL_LINES);
      |            ^
a.cc:4:15: error: expected constructor, destructor, or type conversion before '(' token
    4 |     glVertex2d(-1,0);
      |               ^
a.cc:5:15: error: expected constructor, destructor, or type conversion before '(' token
    5 |     glVertex2d(1,0);
      |               ^
a.cc:6:15: error: expected constructor, destructor, or type conversion before '(' token
    6 |     glVertex2d(-1.5/2,1);
      |               ^
a.cc:7:15: error: expected constructor, destructor, or type conversion before '(' token
    7 |     glVertex2d(-1.5/2,-1);
      |               ^
a.cc:8:12: error: expected constructor, destructor, or type conversion before ';' token
    8 |     glEnd();
      |            ^
a.cc:11:14: error: expected constructor, destructor, or type conversion before '(' token
   11 |     PrintText(-0.8,0,"0");
      |              ^
a.cc:12:10: error: expected constructor, destructor, or type conversion before '(' token
   12 |     Print(-1,0.5,"0.0000001");
      |          ^
a.cc:13:10: error: expected constructor, destructor, or type conversion before '(' token
   13 |     Print(-1,-0.5,"0.0000001");
      |          ^
a.cc:14:14: error: expected constructor, destructor, or type conversion before '(' token
   14 |     PrintText(-0.25,0,"1");
      |              ^
a.cc:15:14: error: expected constructor, destructor, or type conversion before '(' token
   15 |     PrintText(0.25,0,"2");
      |              ^
a.cc:16:14: error: expected constructor, destructor, or type conversion before '(' token
   16 |     PrintText(0.75,0,"3");
      |              ^
a.cc: In function 'void PrintText(double, double, char*)':
a.cc:21:3: error: 'glRasterPos2d' was not declared in this scope
   21 |   glRasterPos2d(w,h);
      |   ^~~~~~~~~~~~~
a.cc:23:25: error: 'GLUT_BITMAP_TIMES_ROMAN_24' was not declared in this scope
   23 |     glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,str[i]);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:23:5: error: 'glutBitmapCharacter' was not declared in this scope
   23 |     glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,str[i]);
      |     ^~~~~~~~~~~~~~~~~~~
a.cc: In function 'void Print(double, double, char*)':
a.cc:28:3: error: 'glRasterPos2d' was not declared in this scope
   28 |   glRasterPos2d(w,h);
      |   ^~~~~~~~~~~~~
a.cc:30:25: error: 'GLUT_BITMAP_TIMES_ROMAN_24' was not declared in this scope
   30 |     glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,str[i]);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:30:5: error: 'glutBitmapCharacter' was not declared in this scope
   30 |     glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,str[i]);
      |     ^~~~~~~~~~~~~~~~~~~