I
Ivan Liu
Hi, I wonder how I can declare a reference in private part of a class
and use it in the member functions. I know I can do it by pointers but
then I have to use pointer syntax, which I hope to avoid.
For instance, what would I write for the following if I were to use
reference instead of a pointer?
template <class T>
class MyClass
{
private:
T * ptr;
public:
MyClass( T * ObjectA ){ ptr = ObjectA; }
double Get() { return ptr->Function_0f_A(x); }
};
and use it in the member functions. I know I can do it by pointers but
then I have to use pointer syntax, which I hope to avoid.
For instance, what would I write for the following if I were to use
reference instead of a pointer?
template <class T>
class MyClass
{
private:
T * ptr;
public:
MyClass( T * ObjectA ){ ptr = ObjectA; }
double Get() { return ptr->Function_0f_A(x); }
};