By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

error: expected unqualified-id before '.' token??

P: 6
Hi all, im new to this programming language and i tried to use my Xcode to build and run this code but i got a error :(, and another error is
i need a help guys





Expand|Select|Wrap|Line Numbers
  1. #include <GLUT/glut.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. const GLdouble twoPi =6.283185;
  6.  
  7. class scrPt {
  8. public:
  9.     GLint x, y;
  10. };
  11.  
  12. GLsizei winWidth = 400, winHeight =300;
  13.  
  14. void init (void)
  15. {
  16.     glClearColor (1.0,1.0,1.0,1.0);
  17.  
  18.     glMatrixMode (GL_PROJECTION);
  19.     gluOrtho2D (0.0,200.0,0.0,150.0);
  20. }
  21. . >>>>> the error is here (error: expected unqualified-id before '.' token)
  22. .
  23. .// Midpoint routines for displaying a circle
  24.  
  25. void pieChart (void)
  26. {
  27.     scrPt circCtr, piePt;
  28.     GLint radius = winWidth/4;
  29.  
  30.     GLdouble sliceAngle, previosSliceAngle = 0.0;
  31.  
  32.     GLint k, nSlices = 12;
  33.     GLfloat dataValues[12] = {10.0,7.0,13.0,5.0,13.0,14.0,3.0,16.0,5.0,3.0,17.0,8.0};
  34.     GLfloat dataSum =0.0;
  35.  
  36.     circCtr.x = winWidth/2;
  37.     circCtr.y =winHeight / 2;
  38.     circleMidpoint (circCtr, radius);
  39.  
  40.     for (k =0; k< nSlices; k++)
  41.         dataSum += dataValues[k];
  42.  
  43.     for (k =0; k< nSlices; k++) {
  44.         sliceAngle =twoPi * dataValues[k]/ dataSum + previousSliceAngle;
  45.         piePt.x = circCtr.x + radius *cos (sliceAngle);
  46.         piePt.y = circCtr.y + radius *sin (sliceAngle);
  47.         glBegin (GL_LINES);
  48.         glVertex2i(circCtr.x, circCtr.y);
  49.         glVertex2i(piePt.x, piePt.y);
  50.         glEnd ();
  51.         previousSliceAngle = sliceAngle;
  52.     }
  53. }
  54.  
  55.  
  56. void displayFcn (void)
  57. {
  58.     glClear (GL_COLOR_BUFFER_BIT);
  59.     glColor3f (0.0,0.0,1.0);
  60.     pieChart (); >>>>>>>>>>>>>>>>( error: 'pieChart' was not declared in this scope )
  61.     glFlush ();
  62. }
  63. void winReshapeFcn (GLint newWidth, GLint newHeight)
  64. {
  65.     glMatrixMode (GL_PROJECTION);
  66.     glLoadIdentity ();
  67.     gluOrtho2D (0.0, GLdouble (newWidth), 0.0, GLdouble (newHeight));
  68.  
  69.     glClear (GL_COLOR_BUFFER_BIT);
  70.  
  71.     /* Reset diaply-window size parameters. */
  72.     winWidth = newWidth;
  73.     winHeight = newHeight;
  74.  
  75. }
  76.  
  77. int main (int argc, char** argv)
  78. {
  79.     glutInit (&argc, argv);
  80.     glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
  81.     glutInitWindowPosition (100,100);
  82.     glutInitWindowSize (winWidth,winHeight);
  83.     glutCreateWindow ("Pie Chart");
  84.  
  85.     init();
  86.     glutDisplayFunc (displayFcn);
  87.     glutReshapeFunc (winReshapeFcn);
  88.  
  89.     glutMainLoop ();
  90.  
  91. }
Feb 19 '10 #1
Share this Question
Share on Google+
12 Replies


100+
P: 687
. >>>>> the error is here (error: expected unqualified-id before '.' token)
.
.//

All these three dots (before '>>>', on the next line , and before '//'), are they in the code? Why are they there?
Feb 19 '10 #2

P: 6
yes they are in the code ... its refer to the Midpoint routines for displaying a circle.
Feb 24 '10 #3

Expert 100+
P: 2,391
Those periods don't look like legal C syntax. What do you expect them to do?
Feb 24 '10 #4

P: 6
Midpoint routines for displaying a circle
Mar 5 '10 #5

Banfa
Expert Mod 5K+
P: 8,916
Have you tried just removing lines 21,22 and 23 and compiling the code?
Mar 5 '10 #6

P: 6
Banfa : yes i tried but its end up with error and when i correct the error my output is a pie chart without a circle :)
Mar 5 '10 #7

Expert 100+
P: 2,391
@sam23
Your source code snippet consists of
  • Include some header files (lines 1-3)
  • Define a global variable (line 5)
  • Define class scrPt (line 7)
  • Define two more global variables (line12)
  • Function init (lines 14-20)
  • Three periods and a comment (lines 21-23)
  • Function pieChart (lines 25-53)
  • Function displayFcn (lines 56-62)
  • Function winReshapeFcn (lines 63-75)
  • Function main (lines 77-end)
Why do you so adamantly believe that the compiler interprets three periods as the instructions for inserting midpoint routines for displaying a circle?

Much more likely is that these periods were meant to be interpreted as an ellipsis in whatever source you cut and pasted this code from. That is, they indicate that a block of code (not needed to make the point) was omitted.
Mar 5 '10 #8

Expert 100+
P: 2,391
@sam23
At line 38, pieChart calls function circleMidpoint -- passing it the center and radius. You don't have a circleMidpoint function. You will need to write it.
Mar 5 '10 #9

P: 6
donbock : i really dont understand :(
My lecturer just gave this coding and ask us to try to run it..
I dont have idea how to write fucntion for this circle Midpoint !
Mar 5 '10 #10

jkmyoung
Expert 100+
P: 2,057
I would consult with your lecturer or teaching assistant as to how to write the midpoint function to complete the code. Perhaps this is the conclusion you are supposed to reach.
Mar 5 '10 #11

P: 52
when you get the code from anybody, better walik through the code, what code is going to do with your system ?. It will help for development/debug knowledge.
Mar 8 '10 #12

P: 6
Sure sri :)
Nandri :)
Mar 14 '10 #13

Post your reply

Sign in to post your reply or Sign up for a free account.