Class Problem

This is a discussion on Class Problem within the C++ Programming forums, part of the General Programming Boards category; Whenever I try to compile my code, these are the errors I get: Code: --------------------Configuration: Life - Win32 Debug-------------------- Compiling... ...

  1. #1
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718

    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( )
    {
    }
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    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!
    }

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Thanks. I've been learning Java at school, and I've started confusing some of the different aspects.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mesh Class Design problem
    By sarah22 in forum Game Programming
    Replies: 2
    Last Post: 05-20-2009, 04:52 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 08:10 AM
  4. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  5. Replies: 3
    Last Post: 12-03-2001, 12:45 PM

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