syntax error

This is a discussion on syntax error within the C++ Programming forums, part of the General Programming Boards category; Code: public: void ShowWindow(bool show); HWND Createwindow(CodeClass *cclass, HWND Parent, int X, int Y, int Width, int Height); CWindow(); virtual ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    161

    syntax error

    Code:
    public:
    	void ShowWindow(bool show);
    	HWND Createwindow(CodeClass *cclass, HWND Parent, int X, int Y, int Width, int Height);
    	CWindow();
    	virtual ~CWindow();
    	HWND hWnd;
    };
    There is a problem for Createwindow. I get an error complaining about CodeClass *cclass. I pushed F1 and it said that the error is caused because the compiler found an identifier that is not expected.

    How can I fix this?
    Thanx in advance!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    Did you

    #include "codeclass.h"

    Or declare
    class CodeClass;

    so it knows what you're talking about
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    161
    CodeClass is a structer. I tryed to just declare it once where the DLLMain function is but then I get too many errors. Thus I declared a few of them where I need it. Now I get 1 error. And that is this. I declared CodeClass before I declared this header.

    Edit:

    I accidently deleted my post before the post below. I didn't expect any one to answer that post that fast.

    >Where is a good place to declare my structure? for me to be able to use it in any class.

    Thanx Salem.
    Last edited by Benzakhar; 12-06-2003 at 05:04 PM.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    In a header file

    Which you then #include in all the places which need to know about that structure

    Don't forget the multiple inclusion guards
    Code:
    #ifndef FILE_INCLUDED
    #define FILE_INCLUDED
    // body of header file
    #endif
    Just see pretty much any header file which comes with your compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Nov 2003
    Posts
    161
    I tryed that and it solved all my problems. As I continued I needed a variable to be accessed by multiple Classes. This variable is the hInstance of my project. I created another variable called Hinstance. Where I placed my class structer for other classes to use it I placed the declaration of the Hinstance varaible. But I get errors saying that the variable is defined more than once. In the file I did something like this;

    #ifndef SHARED_
    HINSTANCE Hinstance
    define SHARED_
    #endif

    How can I make a variable for it to be accessed by other classes in my program?

    Thanx in advance!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 03:09 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 04:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21