472,147 Members | 1,269 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,147 software developers and data experts.

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

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
12 17805
newb16
687 512MB
. >>>>> 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
sam23
6
yes they are in the code ... its refer to the Midpoint routines for displaying a circle.
Feb 24 '10 #3
donbock
2,425 Expert 2GB
Those periods don't look like legal C syntax. What do you expect them to do?
Feb 24 '10 #4
sam23
6
Midpoint routines for displaying a circle
Mar 5 '10 #5
Banfa
9,065 Expert Mod 8TB
Have you tried just removing lines 21,22 and 23 and compiling the code?
Mar 5 '10 #6
sam23
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
donbock
2,425 Expert 2GB
@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
donbock
2,425 Expert 2GB
@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
sam23
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
2,057 Expert 2GB
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
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
sam23
6
Sure sri :)
Nandri :)
Mar 14 '10 #13

Post your reply

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

Similar topics

3 posts views Thread by mavis | last post: by
4 posts views Thread by Igor Koretsky | last post: by
9 posts views Thread by subramanian | last post: by
reply views Thread by =?Utf-8?B?a3Jpc2huYQ==?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.