#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;

#include "NEW.H"

int main()
{

	return 0;

}

and the *.cpp file:

#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;

#include "NEW.H"

 void hangman::LooseLife()
{
	cout << "testing"<<endl;
}

and now the header file....

#ifndef NEW_H
#define NEW_H

class hangman
{
public:

	hangman()
	{
	lives = 1;
	}

void LooseLife();

private:
	int lives;

#endif

putting all that together should work but I get this error :

Compiling...
main.cpp
C:\Documents and Settings\John Rudd\Desktop\hangman\dynaic memory\main.cpp(15) : fatal error C1004: unexpected end of file found
hangman.cpp
C:\Documents and Settings\John Rudd\Desktop\hangman\dynaic memory\hangman.cpp(10) : error C2535: 'void __thiscall hangman::LooseLife(void)' : member function already defined or declared
c:\documents and settings\john rudd\desktop\hangman\dynaic memory\new.h(20) : see declaration of 'LooseLife'
C:\Documents and Settings\John Rudd\Desktop\hangman\dynaic memory\hangman.cpp(15) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

i cant tell whats wrong never done this before lol

Whenever you see 'Unexpected end of file', you'd do well to go back over your functions and classes to see if you've missed a bracket.

It's a subtle error when you've been sitting in front of a computer for hours, so try these little tricks:

1. Whenever you put in an opening bracket, hit enter once or twice and add the closing bracket (and semicolon, if necessary) before you put anything inside the brackets

2. For functions, non-trivial loops and non-trivial if-else statements, put a descriptive
//End of conditional/loop statement function name
comment after the closing bracket. For more complex programs, being able to keep track of which closing bracket corresponds to an opening bracket becomes very helpful.

3. If you can, keep your code indented. VC++ can be stupid about this, so make sure that if you shuffle chunks of code around, you watch for bad formatting. The alt + F8 hotkey for selected text formatting is useful most of the time, though.

This article has been dead for over six months. Start a new discussion instead.