Header Files

Started by
2 comments, last by Sand_Hawk 22 years, 4 months ago
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.
----------------(Inspired by Pouya)
Advertisement
Something like:

Header file:

  #include <iostream.h>#ifndef CLASS_ERROR_HEADER#define CLASS_ERROR_HEADERclass 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_IMPCError::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=-
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.
----------------(Inspired by Pouya)
yes, include the header, but also be sure to add the cpp in your project

This topic is closed to new replies.

Advertisement