Thread: Errors compiling classes with VC++ 6.0

  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    722

    Errors compiling with VC++ 6.0

    I'm currently trying to write a little program to display a openGl window using C++. I'm using VC++ 6.0.

    When compiling I get this error:
    error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class GlWindow *' (or there is no acceptable conversion)


    Code:
    //GlWindow.h
    #ifndef _GLWINDOW_H_
    #define _GLWINDOW_H_
    
    #include <GL/glui.h>
    
    class GlWindow{
    private:
    	int x, y, dimx, dimy, attr, ref;
    	char *title;
    
    public:
    	GlWindow(char *_title);
    	GlWindow();
    
    	GlWindow& setPos(int _x, int _y);
    	GlWindow& setDim(int _dx, int _dy);
    	GlWindow& setAttr(int _attr);
    	int show();
    };
    #endif
    
    //main.c
    #include <GL/glui.h>
    #include "GlWindow.h"
    
    
    void display(void){
    	glClearColor(0.0, 0.0, 0.0, 0.0);
    	glClear(GL_COLOR_BUFFER_BIT);
    	glColor3f(1.0, 1.0, 1.0);
    	glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
    	glBegin(GL_POLYGON);
    	glVertex2f(-0.5, -0.5);
    	glVertex2f(-0.5, 0.5);
    	glVertex2f(0.5, 0.5);
    	glVertex2f(0.5, -0.5);
    	glEnd();
    	glutSwapBuffers();
    }
    
    void keyb(unsigned char key, int x, int y){
    	if (key == 27) exit(0);
    }
    
    int main(int argc, char *argv[]){
    	GlWindow win;
    
    	win = new GlWindow("open Gl");
    	win.setPos(100, 100).setDim(300, 300);
    	win.show();
    
    	glutKeyboardFunc(keyb);
    	glutDisplayFunc(display);
    
    	glutMainLoop();
    
    	return 0;
    }
    Thanks in advance.
    Last edited by xErath; 07-02-2004 at 12:26 AM.

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    13
    Hi

    try this:

    Code:
    	
    
    	GlWindow* win;
    
    	win = new GlWindow("open Gl");
    	win->setPos(100, 100).setDim(300, 300);
    	win->show();

  3. #3
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    Arghhh!!
    I'm terribly used to Java, and the implict pointer stuff...
    sorry.
    Last edited by xErath; 07-02-2004 at 08:01 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling errors
    By courtesan in forum C Programming
    Replies: 2
    Last Post: 08-18-2005, 10:52 AM
  2. compiling error with classes
    By zeni3773 in forum C++ Programming
    Replies: 6
    Last Post: 10-14-2002, 06:44 PM
  3. ListView Version 6.0 and ImageLists
    By blundstrom in forum Windows Programming
    Replies: 0
    Last Post: 07-26-2002, 09:35 AM
  4. Classes Compiler Errors
    By taiDasher in forum C++ Programming
    Replies: 5
    Last Post: 07-03-2002, 08:11 AM
  5. errors with classes (again)
    By neandrake in forum C++ Programming
    Replies: 1
    Last Post: 03-18-2002, 08:37 PM