K
ken.carlino
Hi,
Can I use Reference type as my class attribute, like this? Or I have to
use pointers for class attribute?
class B;
class A {
public:
B& _b;
};
If yes, how can I init the class attribute?
I try this:
A::A(const B& b)
{
_b = b;
}
I get this error "error: uninitialized reference member "
I try this:
A::A (const B& b) :
_b(b)
{
}
I get this error "error: invalid initialization of reference of type "
or I have to use Pointers ?
Can I use Reference type as my class attribute, like this? Or I have to
use pointers for class attribute?
class B;
class A {
public:
B& _b;
};
If yes, how can I init the class attribute?
I try this:
A::A(const B& b)
{
_b = b;
}
I get this error "error: uninitialized reference member "
I try this:
A::A (const B& b) :
_b(b)
{
}
I get this error "error: invalid initialization of reference of type "
or I have to use Pointers ?