unexpected 'class Window (' ??? i dont understand the error

This is a discussion on unexpected 'class Window (' ??? i dont understand the error within the C++ Programming forums, part of the General Programming Boards category; im getting a few errors when i try to compile my program. here is what i get: e:\c++\dx\clswindow.cpp(5) : error ...

  1. #1
    Unregistered
    Guest

    unexpected 'class Window (' ??? i dont understand the error

    im getting a few errors when i try to compile my program. here is what i get:
    e:\c++\dx\clswindow.cpp(5) : error C2629: unexpected 'class Window ('
    e:\c++\dx\clswindow.cpp(5) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body

    E:\c++\dx\main.cpp(27) : error C2661: 'Window::Window' : no overloaded function takes 3 parameters

    here is some of my code:

    class Window
    {
    public:
    Window(int Height, Width, long ColorKey) *****The first two errors point here.*****
    {
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_CKSRCBLT;
    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
    ddsd.dwHeight = Height;
    ddsd.dwWidth = Width;
    // Set the source color key to green.
    ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = ColorKey;
    ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = ColorKey;

    if (FAILED(lpDD->CreateSurface(&ddsd, &DDSPrimary, NULL)))
    {
    return Fail(hwnd, "Couldn't create off-screen one.\n");
    }
    }

    LoadPic(LPSTR File)
    {
    LoadImage(DDSPrimary, File)
    }

    ~Window()
    {
    if (DDSPrimary != NULL)
    {
    DDSPrimary->Release();
    DDSPrimary = NULL;
    }
    }


    LPDIRECTDRAWSURFACE DDSPrimary; //Primary DD Surface

    private:
    DDSURFACEDESC ddsd; //The Direct Draw description

    };

    and the last error points here:
    main.cpp:
    Window winTest(100,100,0);

    so, can anyone help me? im a beginer in c++, but i have programmed for around 9-10 years.

    TIA
    Echo

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >Window(int Height, Width, long ColorKey) *****The first two errors point here.*****

    you left out the type, should be:
    Window(int Height, int Width, long ColorKey)

  3. #3
    Unregistered
    Guest

    one more error, and question on warnings

    thx, but now i have a few more questions

    i dont understand where this error is coming from
    e:\c++\dx\clswindow.cpp(24) : error C2660: 'LoadImageA' : function does not take 2 parameters

    i dont have a LoadImageA function, i have a LoadImage function
    here is the first part of that function
    bool LoadImage(LPDIRECTDRAWSURFACE lpDDS, LPSTR szImage)
    {

    the error poings to this line:
    LoadImage(DDSPrimary, File);
    where File is LPSTR and DDSPrimary is LPDIRECTDRAWSURFACE
    i dont understand what is wrong.

    it also says that this this
    if (~DestKey)
    is unsafe. is it realy unsafe? i probley should try to night have any warnings right?

    thanks for everything.
    Echo

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    1) For the LoadImageA thing, probably part of the problem is that there is already a "LoadImage()" function defined by Windows GDI. Try renaming the function.

    2) "if(~DestKey)" calls DestKey's destructor. Most of the time, you shouldn't call it yourself because it will be called automatically when the variable goes out of scope... and if you try using DestKey after the if statement, then your program will probably crash because DestKey has been destroyed already.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #5
    Unregistered
    Guest
    thank you, that helped a lot. but once again im getting some errors. but think time, they are link errors.

    main.obj : error LNK2005: "struct HWND__ * hwnd" (?hwnd@@3PAUHWND__@@A) already defined in clsWindow.obj
    main.obj : error LNK2005: "struct IDirectDraw * lpDD" (?lpDD@@3PAUIDirectDraw@@A) already defined in clsWindow.obj

    i dont see where im defining it twice. here is the only code where it is defined. it is in a header file.
    Code:
    #include <windows.h> 
    #include <windowsx.h> // For windows messages and API's 
    #include <ddraw.h>  // Direct Draw header 
    
    bool Fail(HWND hwnd,  char *szMsg); 
    bool ImageLoad(LPDIRECTDRAWSURFACE lpDDS, LPSTR szImage);
    
    LPDIRECTDRAW        lpDD; // DirectDraw object
    HWND
    the only thing i can think of is that it is using it twice. how can i fix this?

    TIA
    Echo

    p.s. why can't i registor? it wont take my email. it says its invailed.

  6. #6
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Did you make or include a clsWindow.h? Judging from your errors, it looks like you might have included a header that was incompatible with windows.h (e.g. once, I was taking a class and the instructor person said that you can't include both winsock.h and windows.h together, otherwise you'll get an error...) I personally have no real experience with this, but that's somewhere you might want to try starting with.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 05:02 PM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 11:52 PM

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