SC++ bugs
1 messages in this thread
I posted this message several weeks ago but received NO response. So here it is
again…
———————————————————–
The following code compiled fine under Borland C++ but had errors under SC++.
The errors are indicated with comments. In particular, the problems were:
(1) failure to recognize an access declaration
(2) failure to allow a friend class access to a private enum constant
(3) failure to resolve a class name via the "class" keyword
#include <string.h>
class StringKey
{
friend class State;
public:
operator int() { return key; }
virtual const char* get_string(void);
protected:
int key;
private:
enum { defaultSize = 10 };
};
class State : private StringKey
{
public:
StringKey::operator int; // Error: empty declaration
State(int k) { key = k; }
const char* get_string();
private:
int array[StringKey::defaultSize]; /* Error: member 'StringKey::defaultSize'
of class 'State' is not accessible */
};
const char* State::get_string()
{
static char stateString[16];
switch(key)
{
case 1:
strcpy(stateString, "Oregon");
break;
case 2:
strcpy(stateString, "Washington");
break;
default:
strcpy(stateString, "Unknown");
}
return stateString;
}
void main()
{
int State;
class State state; // Error: size of type is not known
}