-
Class Problem
Whenever I try to compile my code, these are the errors I get:
Code:
--------------------Configuration: Life - Win32 Debug--------------------
Compiling...
CLife.cpp
C:\C++\Life\CLife.cpp(3) : error C2143: syntax error : missing ';' before 'public'
C:\C++\Life\CLife.cpp(4) : error C2143: syntax error : missing ';' before '{'
C:\C++\Life\CLife.cpp(4) : error C2447: missing function header (old-style formal list?)
C:\C++\Life\CLife.cpp(7) : error C2143: syntax error : missing ';' before 'public'
C:\C++\Life\CLife.cpp(8) : error C2143: syntax error : missing ';' before '{'
C:\C++\Life\CLife.cpp(8) : error C2447: missing function header (old-style formal list?)
C:\C++\Life\CLife.cpp(11) : error C2143: syntax error : missing ';' before 'public'
C:\C++\Life\CLife.cpp(12) : error C2143: syntax error : missing ';' before '{'
C:\C++\Life\CLife.cpp(12) : error C2447: missing function header (old-style formal list?)
Error executing cl.exe.
Life.exe - 9 error(s), 0 warning(s)
CLife.h
Code:
#ifndef CLIFE_H_
#define CLIFE_H_
class Life
{
public:
Life( );
Life( int );
~Life( );
};
#endif
CLife.cpp
Code:
#include "CLife.h"
public Life::Life( )
{
}
public Life::Life( int param0 )
{
}
public Life::~Life( )
{
}
-
Don't put public in your cpp file. Should just be like this
Life.cpp
Code:
// Default constructor
Life::Life( )
{
}
// Random member function
void Life::SomeFunction( void *lpParam )
{
// Something exciting!
}
-
Thanks. I've been learning Java at school, and I've started confusing some of the different aspects.