![]() |
| | #1 |
| Registered User Join Date: Jul 2008
Posts: 2
| classes in windows programming ![]() 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
};
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 : '}'
|
| Struja is offline | |
| | #2 |
| C++ Witch 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 | |
| | #3 |
| Registered User Join Date: Jul 2008
Posts: 2
| so i cant define classes in C code ? o0 |
| Struja is offline | |
| | #4 | |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,354
| Quote:
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 | |
![]() |
| Tags |
| class, windows |
| Thread Tools | |
| Display Modes | |
|
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 |