static const char

I don't know what i'm doing wrong but i'm having a heck of a time declaring USEP as a static const char initialized to \x1F;

here is my header file:

#include <iostream.h>
#include <fstream.h>

#ifndef CRunLen_H
#define CRunLen_H

class CRunLen
{
//public data
public:
CRunLen();
CRunLen(char *, char *);
~CRunLen();
void compress();
void decompress();

//private data
private:
ofstream dfs;// the destination file stream
ifstream sfs;// the source file stream
static const char USEP='\x1F';

};
#endif

errors:
Deleting intermediate files and output files for project 'CRunLen - Win32 Debug'.
-------Configuration: CRunLen - Win32 Debug-------
Compiling...
CRunLen.cpp
c:\hw\266\lab11\crunlen.h(27) : error C2258: illegal pure syntax, must be '= 0'
c:\hw\266\lab11\crunlen.h(27) : error C2252: 'USEP' : pure specifier can only be specified for functions
c:\hw\266\lab11\crunlen.cpp(36) : error C2065: 'USEP' : undeclared identifier
c:\hw\266\lab11\crunlen.cpp(62) : error C2051: case expression not constant
c:\hw\266\lab11\crunlen.cpp(77) : warning C4065: switch statement contains 'default' but no 'case' labels
Error executing cl.exe.

CRunLen.exe - 4 error(s), 1 warning(s)

help a newbie out! Thanks!
[1574 byte] By [npis2001] at [2007-11-18 19:14:38]
# 1 Re: static const char
You are probably using using Visual C++ Version 6 or earlier
which does not recognize that valid construct.

change the header to :

static const char USEP;

and then in CRunLen.cpp, add the following after the
include, but outside of any function :

const char CRunLen::USEP = '\x1F';
Philip Nicoletti at 2007-11-9 0:32:19 >
# 2 Re: static const char
First, this code compiles with the Comeau C++ compiler. You didn't mention which compiler you are using:

#ifndef CRunLen_H
#define CRunLen_H

#include <iostream>
#include <fstream>

class CRunLen
{
public:
CRunLen();
CRunLen(char *, char *);
~CRunLen();

void compress();
void decompress();

//private data
private:
std::ofstream dfs;// the destination file stream
std::ifstream sfs;// the source file stream
static const char USEP='\x1F';
};

#endif

Also, note the usage of <iostream> and <fstream>, not <iostream.h> and <fstream.h>. The latter are non-standard headers, the <iostream> and <fstream> are the standard C++ headers.

If you are using Visual C++ 6.0, then this won't compile since it isn't as ANSI compliant as Comeau C++.

Regards,

Paul McKenzie
Paul McKenzie at 2007-11-9 0:33:19 >
# 3 Re: static const char
Thanks alot guys! That worked. This forum rocks! By the way I'm using visual C++ 6.

Npis
npis2001 at 2007-11-9 0:34:22 >