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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sam23
    New Member
    • Feb 2010
    • 6

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

    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





    Code:
    #include <GLUT/glut.h>
    #include <stdlib.h>
    #include <math.h>
    
    const GLdouble twoPi =6.283185;
    
    class scrPt {
    public:
    	GLint x, y;
    };
    
    GLsizei winWidth = 400, winHeight =300;
    
    void init (void)
    {
    	glClearColor (1.0,1.0,1.0,1.0);
    	
    	glMatrixMode (GL_PROJECTION);
    	gluOrtho2D (0.0,200.0,0.0,150.0);
    }
    . >>>>> the error is here (error: expected unqualified-id before '.' token)
    .
    .// Midpoint routines for displaying a circle
    
    void pieChart (void)
    {
    	scrPt circCtr, piePt;
    	GLint radius = winWidth/4;
    	
    	GLdouble sliceAngle, previosSliceAngle = 0.0;
    	
    	GLint k, nSlices = 12;
    	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};
    	GLfloat dataSum =0.0;
    	
    	circCtr.x = winWidth/2;
    	circCtr.y =winHeight / 2;
    	circleMidpoint (circCtr, radius);
    	
    	for (k =0; k< nSlices; k++)
    		dataSum += dataValues[k];
    	
    	for (k =0; k< nSlices; k++) {
    		sliceAngle =twoPi * dataValues[k]/ dataSum + previousSliceAngle;
    		piePt.x = circCtr.x + radius *cos (sliceAngle);
    		piePt.y = circCtr.y + radius *sin (sliceAngle);
    		glBegin (GL_LINES);
    		glVertex2i(circCtr.x, circCtr.y);
    		glVertex2i(piePt.x, piePt.y);
    		glEnd ();
    		previousSliceAngle = sliceAngle;
    	}
    }
    
    
    void displayFcn (void)
    {
    	glClear (GL_COLOR_BUFFER_BIT);
    	glColor3f (0.0,0.0,1.0);
    	pieChart (); >>>>>>>>>>>>>>>>( error: 'pieChart' was not declared in this scope )
    	glFlush ();
    }
    void winReshapeFcn (GLint newWidth, GLint newHeight)
    {
    	glMatrixMode (GL_PROJECTION);
    	glLoadIdentity ();
    	gluOrtho2D (0.0, GLdouble (newWidth), 0.0, GLdouble (newHeight));
    	
    	glClear (GL_COLOR_BUFFER_BIT);
    	
    	/* Reset diaply-window size parameters. */
    	winWidth = newWidth;
    	winHeight = newHeight;
    	
    }
    
    int main (int argc, char** argv)
    {
    	glutInit (&argc, argv);
    	glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    	glutInitWindowPosition (100,100);
    	glutInitWindowSize (winWidth,winHeight);
    	glutCreateWindow ("Pie Chart");
    	
    	init();
    	glutDisplayFunc (displayFcn);
    	glutReshapeFunc (winReshapeFcn);
    	
    	glutMainLoop ();
    	
    }
    Last edited by Banfa; Feb 24 '10, 09:26 AM. Reason: Added code tags
  • newb16
    Contributor
    • Jul 2008
    • 687

    #2
    . >>>>> 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?

    Comment

    • sam23
      New Member
      • Feb 2010
      • 6

      #3
      yes they are in the code ... its refer to the Midpoint routines for displaying a circle.

      Comment

      • donbock
        Recognized Expert Top Contributor
        • Mar 2008
        • 2427

        #4
        Those periods don't look like legal C syntax. What do you expect them to do?

        Comment

        • sam23
          New Member
          • Feb 2010
          • 6

          #5
          Midpoint routines for displaying a circle

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            Have you tried just removing lines 21,22 and 23 and compiling the code?

            Comment

            • sam23
              New Member
              • Feb 2010
              • 6

              #7
              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 :)

              Comment

              • donbock
                Recognized Expert Top Contributor
                • Mar 2008
                • 2427

                #8
                Originally posted by sam23
                Midpoint routines for displaying a circle
                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.
                Last edited by donbock; Mar 5 '10, 01:41 PM. Reason: second thoughts

                Comment

                • donbock
                  Recognized Expert Top Contributor
                  • Mar 2008
                  • 2427

                  #9
                  Originally posted by sam23
                  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 :)
                  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.

                  Comment

                  • sam23
                    New Member
                    • Feb 2010
                    • 6

                    #10
                    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 !

                    Comment

                    • jkmyoung
                      Recognized Expert Top Contributor
                      • Mar 2006
                      • 2057

                      #11
                      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.

                      Comment

                      • sridhard2406
                        New Member
                        • Dec 2007
                        • 52

                        #12
                        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.

                        Comment

                        • sam23
                          New Member
                          • Feb 2010
                          • 6

                          #13
                          Sure sri :)
                          Nandri :)

                          Comment

                          Working...