Slimelite BBS

Initializing Reference Member

Back to EMULATE

From Darin McBride · 1996-04-11 04:36 · #73594 in EMULATE

Hello Adedayo!

08 Apr 96 23:33, Adedayo Taylor wrote to All:

 AT> Can someone please let me know how to initialize a reference
 AT> identifier, nothing I've tried so far gets rid of the "reference
 AT> identifier not initialized" error.  My class looks something
 AT> like this:


 AT> class X : public Base
 AT> {
 AT> public:
 AT>     X(int & _YRef);
 AT>     ~X();
 AT>     int & YRef;
 AT> };


 AT> I need YRef to occupy _YRef.

Although I don't know WHY you would do this, it would be:

class X: public Base // can we see Base as well?
{
public:
        X(int& _YRef);
        ~X();
        int& YRef; // should make it private, though...
};

// and in the .cpp:
X::X(int& _YRef) : YRef(_YRef)
{
// init code...
}

Darin McBride

--- GoldED/2 2.42.G0614
 * Origin: Tanktalus' Tower BBS/RPGs Galore! (1:342/5015)