Archived

This topic is now archived and is closed to further replies.

Sand_Hawk

Header Files

Recommended Posts

Sand_Hawk    108
Hi there, I have a it experience with C++ and am still learning. But I''ve never came across Header files. Now for my programming team I''ve written a error logging class(Simple one) and I want to split it up in a heaader and cpp file. How do I do this and how do the files look like. What I want is just this: #include "errorlog.h" // Do other stuff here How does the .H file look like and how does the cpp file look like. I also want to distribute it as an precompiled header on the team site, how do I create an precompiled header?(Using VC++ 6 Enterprise). Thanx in advance, Sand Hawk Member of the Stupid Coders. http://www.stupidcoders.cjb.net -Earth is 98% full. Please delete anybody you can.

Share this post


Link to post
Share on other sites
RageMatrix    133
Something like:

Header file:

  
#include <iostream.h>

#ifndef CLASS_ERROR_HEADER
#define CLASS_ERROR_HEADER

class CError
{
public:
CError();
~CError();
void LogError(char *error);
void DisplayError(void);
private:
// whatever storage variables you want....

}
#endif



and the cpp file...

  
#include "CError.h"

#ifndef CLASS_CERROR_IMP
#define CLASS_CERROR_IMP

CError::CError()
{
// whatever code...

}

CError::~CError()
{
// whatever code...

}

void CError::LogError(char *error)
{
// whatever code...

}

void CError::DisplayError(void)
{
// whatever code...

}
#endif



Hope this helps some....if you''re stuck, check out a good C++ book.

Regards,

RM.


Tron Software

-=Kicking Butt and Writing Code=-

Share this post


Link to post
Share on other sites
Sand_Hawk    108
And how do I incorporate this in my program? Just include the header or something??

Member of the Stupid Coders.
http://www.stupidcoders.cjb.net

-Earth is 98% full. Please delete anybody you can.

Share this post


Link to post
Share on other sites