error C2059: syntax error : 'public'

I'm using the GDI+ API to manipulate images in a program I'm working on. I've taken code samples from the MSDN web page, and using them almost verbatim, I'm still getting compile error. The following code snippet is where I get the error from:

#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;

void main()
{
Image image(L"Grapes.jpg");
graphics.DrawImage(&image, 60, 10);
}

and the error:

image.cpp(8) : error C2065: 'graphics' : undeclared identifier
image.cpp(8) : error C2228: left of '.DrawImage' must have class/struct/union
type is ''unknown-type''

I thought 'graphics' was a part of GDI+. Is there something I'm missing here? Any help I can get to shed some light would be most appreciated.
The example assumes you already created an object called 'graphics' of type Graphics.
http://msdn.microsoft.com/en-us/library/ms534453(VS.85).aspx
You need to declare graphics ( as instance of the class Graphics ) http://msdn.microsoft.com/en-us/library/ms534453%28VS.85%29.aspx

Edit: too slow
Last edited on
Yes, I kind of figured that out after staring at my code long enough. Thanks, I feel stupid for asking now.
Topic archived. No new replies allowed.