I have a class called String with no ctor written, it has a private member
char s[maxlen+1];
which is not set until this method is called:
void assign (char const *st)
{
strcpy(s,st);
len=strlen(st);
}
In another class called Tick I have a member of type String
String name;
I want to write a copy constructor for the Tick class:
Tick::Tick( const Tick & obj )
{
// Here are a bunch of primitive types copied
// which I removed to keep it short
name.assign(obj.name.s);
}
The String class does not have a return type for s, but I thought this should not be a problem as I have member name which is of type String and is able to access all members of an object of the same type. The compiler gives me the following error:
error C2248: 'String::s' : cannot access private member declared in class 'String'