M
Michael S.
Hi
I'm having some problems with a class for large Integers (called
Xuint).
I want (have) to implement it like this:
- using a simple linked list
- a reference-objekt for each value, which means if 2 Xuint-objekts
have the same value, only one list is in memory and the 2
Xuint-objekts are pointing to the ref-objekt which points to the list.
By now I have this:
class Xuint
{
//listnode
struct Xunode{
unsigned short nodeval;
Xunode *next;
};
//ref-objekt
class Rep{
friend class Xuint;
Xunode *xustart;
int refs;
//...
};
public:
//...
};
When I compile this with Forte Developer C++ 5.4 I get:
"Error: Xuint::Xunode is not accessible from Xuint::Rep"
If I make Xunode public it works, but I don't understand why, because
from my point of view the 'friend class Xuint;' should make the
private parts of Xuint accessible to Rep.
So here's the question: what am I doing wrong and is there a way to
keep Xunode private while using it from Rep?
regards,
Michael
I'm having some problems with a class for large Integers (called
Xuint).
I want (have) to implement it like this:
- using a simple linked list
- a reference-objekt for each value, which means if 2 Xuint-objekts
have the same value, only one list is in memory and the 2
Xuint-objekts are pointing to the ref-objekt which points to the list.
By now I have this:
class Xuint
{
//listnode
struct Xunode{
unsigned short nodeval;
Xunode *next;
};
//ref-objekt
class Rep{
friend class Xuint;
Xunode *xustart;
int refs;
//...
};
public:
//...
};
When I compile this with Forte Developer C++ 5.4 I get:
"Error: Xuint::Xunode is not accessible from Xuint::Rep"
If I make Xunode public it works, but I don't understand why, because
from my point of view the 'friend class Xuint;' should make the
private parts of Xuint accessible to Rep.
So here's the question: what am I doing wrong and is there a way to
keep Xunode private while using it from Rep?
regards,
Michael