C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-08-2008, 01:44 PM   #1
Registered User
 
Join Date: Jul 2008
Posts: 2
classes in windows programming

i dont know how to search for a solution for this, so i'll make a new topic for it. first poster

anyway. i have 2 programs, both made in C, only one is windows programming, using win API and all that, the other is a console project.

in the console program i made my own classes, and it all worked fine.
in the windows program, the exact same definition of the class as in the console program, doesn't work, as VStudio drops me a lot of syntax errors about the class definition.

now, my question is: does defining classes when programming windows work differently, or it doesn't work at all ? =/


Code:
class character {
private:
	int num;
	char name[30];
public:
	//methods
};
this passes ok when building a console project.
but when i put this in a .c file which has the WinMain() function and everything else related, i get these syntax errors:
Code:
d:\my docs\Visual Studio Projects\struja_igra\strukture.h(15): error C2061: syntax error : identifier 'character'
d:\my docs\Visual Studio Projects\struja_igra\strukture.h(15): error C2059: syntax error : ';'
d:\my docs\Visual Studio Projects\struja_igra\strukture.h(15): error C2449: found '{' at file scope (missing function header?)
d:\my docs\Visual Studio Projects\struja_igra\strukture.h(15): error C2059: syntax error : '}'
and so on. anyone got any advice for this ? thx
Struja is offline   Reply With Quote
Old 07-08-2008, 01:45 PM   #2
C++ Witch
 
laserlight's Avatar
 
Join Date: Oct 2003
Location: Singapore
Posts: 10,354
You are writing C++ code, but compiling as C. So it is not a matter of programming for Windows, but trying to pretend that C++ code is C code.
__________________
C + C++ Compiler: MinGW port of GCC
Build + Version Control System: SCons + Bazaar

Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
laserlight is offline   Reply With Quote
Old 07-08-2008, 01:51 PM   #3
Registered User
 
Join Date: Jul 2008
Posts: 2
so i cant define classes in C code ? o0
Struja is offline   Reply With Quote
Old 07-08-2008, 01:55 PM   #4
C++ Witch
 
laserlight's Avatar
 
Join Date: Oct 2003
Location: Singapore
Posts: 10,354
Quote:
so i cant define classes in C code ?
Yes. You can define structs, but C structs are a subset of C++ structs (which are pretty much equivalent to C++ classes).

The good news is that you can mix C and C++, so you do not have to restrict yourself to programming in C. Read this FAQ on How to mix C and C++.
__________________
C + C++ Compiler: MinGW port of GCC
Build + Version Control System: SCons + Bazaar

Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
laserlight is offline   Reply With Quote
Reply

Tags
class, windows

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make a windows application crvenkapa C++ Programming 3 03-26-2007 09:59 AM
dual boot Win XP, win 2000 Micko Tech Board 6 05-30-2005 02:55 PM
input/output dogbert234 Windows Programming 11 01-26-2005 06:57 AM
Question.. pode Windows Programming 12 12-19-2004 07:05 PM
Manipulating the Windows Clipboard Johno Windows Programming 2 10-01-2002 09:37 AM


All times are GMT -6. The time now is 12:12 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

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