Author Topic: Compiling Error: class  (Read 4261 times)

Offline CoderTimm

  • Single posting newcomer
  • *
  • Posts: 3
Compiling Error: class
« on: August 07, 2005, 06:28:17 pm »
Hi!
I switched from Microsoft Visual C++ 6 to Code::Blocks.
First it works fine... but soon i get an error.
I wanted to create a class... but why it dont works?
Code:
Code: [Select]
class Test
{
public:
Test();
~Test();
protected:

private:

};
But when i compile it ... i get some errors:
Code: [Select]
error: syntax error before 'Test'
error: syntax error before '{' token
When i compile it with MSVCPP 6 it works fine...
Any ideas?
_____________________________________________
Additionally I have got a dislike in the Class Wizard Plugin:
I think it should be more integrated.
And the Filenaming for the class CTest... is ctest.cpp and ctest.h... where can I change the
Filenaming to Test.cpp...
_____________________________________________

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Compiling Error: class
« Reply #1 on: August 08, 2005, 01:03:03 am »
I don't know about the compiler errors.. your code compiles just fine under MinGW. Are you sure there's not an included file somewhere that screws it up?


Offline squizzz

  • Almost regular
  • **
  • Posts: 132
Re: Compiling Error: class
« Reply #2 on: August 08, 2005, 01:15:30 am »
This files compiles fine under my VC Toolkit 2003 as well...

Could you specify exact steps you take after C::B startup until you get these errors?

Quote
And the Filenaming for the class CTest... is ctest.cpp and ctest.h... where can I change the
Filenaming to Test.cpp...

Maybe here? :?
Anyway, it is rather good practice to name your source files just the same as the class they implement.
« Last Edit: August 08, 2005, 01:19:43 am by squizzz »
this space is for rent

Offline CoderTimm

  • Single posting newcomer
  • *
  • Posts: 3
Re: Compiling Error: class
« Reply #3 on: August 08, 2005, 11:42:54 am »
...ehm... 3 days lasted since install... but i uninstalled code::blocks and installed it again... but no change  :(
Everytime he say he doesn't know class ... that's confusing because he knows public: and private:, but when he gets to
protected: he writes a syntax error  :x
... i think the problem is caused by the code::blocks editor... i compiled it with code::blocks and the microsoft visual c++ 6 compiler and it dont work...
Edit: I think the compiler or the editor interprete it like a function... because when i change the Position of the classname to the end he wants to have brackets... Example:
Code: [Select]
class
{
public:
CTest();
~CTest();
protected:

private:

} CTest;
Now he wants brackets:

Code: [Select]
class()
{
public:
CTest();
~CTest();
protected:

private:

} CTest;
But its definately Wrong!!! Any ideas?
« Last Edit: August 08, 2005, 11:53:27 am by CoderTimm »

Offline squizzz

  • Almost regular
  • **
  • Posts: 132
Re: Compiling Error: class
« Reply #4 on: August 08, 2005, 12:37:22 pm »
Are you sure your file is saved with *.cpp extension? I get similar errors like yours when I save it as *.c :)
this space is for rent

Offline CoderTimm

  • Single posting newcomer
  • *
  • Posts: 3
Re: Compiling Error: class
« Reply #5 on: August 08, 2005, 12:49:49 pm »
 :shock:
Yea it works... Thanks... Thanks a lot...
 :)