Apr 26, 2008 at 4:14am Apr 26, 2008 at 4:14am UTC
REPOSTED THE PROBLEM BELOW WITH ALL SUGGESTED IMPROVEMENTS. STILL PROBLEMS THOUGH!
THANKS GUYS
Last edited on Apr 26, 2008 at 4:44pm Apr 26, 2008 at 4:44pm UTC
Apr 26, 2008 at 4:40pm Apr 26, 2008 at 4:40pm UTC
OK, I've tried to tidy this up to make it a bit clearer. I've implemented the suggestions above, but still no luck. The error is caused by the member definition:
utilities::CLogFile m_Log("global_log",LOG_ALL,1);
//returns - error C2059: syntax error : 'string'
Heres the header with the compiler error:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
///////////////////////////////////////////////////////////////////////
// myConsoleApplication.h
///////////////////////////////////////////////////////////////////////
#pragma once
#include "CConsoleApplication.h"
#include "../Utilities/CLogFile.h"
#include "../Utilities/CTimer.h"
///////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////
class myConsoleApplication : public CConsoleApplication
{
// add pre Main initialisation procedures
DECLARE_INITIALISE;
public :
myConsoleApplication ();
virtual ~myConsoleApplication ();
virtual int Main (int iNumArgs, char ** apcArgs);
private :
utilities::CLogFile m_Log("global_log" ,LOG_ALL,1);
//####### - error C2059: syntax error : 'string'
utilities::CTimer m_Timer;
};
///////////////////////////////////////////////////////////////////////
// implement the pre Main initialisation
REGISTER_INITIALISE(myConsoleApplication);
And heres a reduced class with zero functionality (but still the error)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
///////////////////////////////////////////////////////////////////////
// CLogFile
///////////////////////////////////////////////////////////////////////
#pragma once
#include <list>
#include <string>
#include <fstream>
#include <ctime>
#include <cstdio>
#include <cstdarg>
// add to the utilities namespace
namespace utilities
{
///////////////////////////////////////////////////////////////////////
// types of valid log entry
enum eLogEntryType
{
LOG_GENERAL = 0,
LOG_WARNING,
LOG_DEBUG,
LOG_ALL
};
///////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////
class CLogFile
{
///////////////////////////////////////////////////////////////////
public :
CLogFile(const char * csName, eLogEntryType eLogPolicy = LOG_ALL, unsigned int uiFlushSize = 30)
{};
};
///////////////////////////////////////////////////////////////////////
} // close utilities namespace
///////////////////////////////////////////////////////////////////////
Is there a problem with my member defn?
Last edited on Apr 26, 2008 at 4:46pm Apr 26, 2008 at 4:46pm UTC
Apr 26, 2008 at 5:32pm Apr 26, 2008 at 5:32pm UTC
You can't initialize m_Log like that. You need to initialize it in the constructor:
1 2 3 4
myConsoleApplication ()
:m_log("global_log" ,LOG_ALL,1);
....
utilities::CLogFile m_log;
I hope this helps! ^_^
rpgfan
Last edited on Apr 26, 2008 at 5:33pm Apr 26, 2008 at 5:33pm UTC
Apr 26, 2008 at 6:31pm Apr 26, 2008 at 6:31pm UTC
Ahhhh ..... Initialization Lists(?) Never really used or paid any real attention to them in examples! Time to read up on them i think!
Thanks rpgfan and everyone else who offered advice. It's appreciated!
Doug
Apr 26, 2008 at 7:21pm Apr 26, 2008 at 7:21pm UTC
Yep, initialization lists. Just beware of them when you play with virtual inheritance. They come back to bite you. ;)