user35512: I'm having trouble explaining my issue. What I'm doing is creating a library to work easily with the RFID reader/writer RC522 module. I need to create an object of the library MFRC522 in my .cpp file to be able to communticate with the module itself. I want my constructor end up like this:UltimateRFID rfid(53, 5);, the parameters being the slave select and the reset pins, respectively. 
The problem is that I don't know how to make my constructor so that it is within the scope of the functions that require the MFRC522 object to be called. Below's my code.
#include "Arduino.h"
#include "UltimateRFID.h"
#include <MFRC522.h>


MFRC522::MIFARE_Key key;


UltimateRFID::UltimateRFID(int ss, int rst)
{
   MFRC522 mfrc522(ss, rst); //this would be ideal, but how can my functions access the instance?
}


void UltimateRFID::initialize() //sample of a function that uses the MFRC522 object
{
  //digitalWrite(49, HIGH);
  digitalWrite(2, LOW);
  for (byte i = 0; i < 6; i++) {
    key.keyByte[i] = 0xFF;
  }     
  mfrc522.PCD_Init();
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;          
  }

}

Now comes my header file, although I'm not sure it matters much.
#ifndef UltimateRFID_h
#define UltimateRFID_h

#include "Arduino.h"
#include <MFRC522.h>

class UltimateRFID
{
  public:
    UltimateRFID(int ss, int rst);
    void initialize();
  private:
    MFRC522::MIFARE_Key key;
};

#endif

Please be patient, it's my first library.

user10794: UltimateRFID::UltimateRFID(int ss, int rst)
{
   MFRC522 mfrc522(ss, rst); //this would be ideal, but how can my functions access the instance?
}

As you note, that instance would go out of scope immediately. The simplest thing would be to put a pointer to the other class in your class definition. Then in your init function do a new to create the instance of the class, passing the appropriate parameters.

user13425: While @Majenko's answer is probably best (I +1'd it), for completeness, here's how to construct a member variable with parameters:
class UltimateRFID {
    public:
    UltimateRFID(int ss, int rst) : mfrc522(ss, rst) {}

    protected:
    MFRC522 mfrc522;
};

"placement new" is another option:
class UltimateRFID {
    public:
    UltimateRFID(int ss, int rst) {
        new (&mfrc522) MFRC522(ss, rst)
    }

    protected:
    MFRC522 mfrc522;
};

However, this method calls the default ctor - which may or may not be an issue. This is usually reserved for re-initializing an existing object.
There's also assignment:
class UltimateRFID {
    public:
    UltimateRFID(int ss, int rst) {
        mfrc522 = MFRC522(ss, rst)
    }

    protected:
    MFRC522 mfrc522;
};

This also calls the default ctor and works best if the class provides operator=.

user4143: Why not have your class just extend the MFRC522 class?
#include <MFRC522.h>

class UltimateRFID : public MFRC522 {
    private:
        MIFARE_Key key;

    public: 
        UltimateRFID(uint8_t ss, uint8_t rst) : MFRC522(ss, rst) {}
        // your other methods
        void initialize();
};

void UltimateRFID::initialize() {
    //digitalWrite(49, HIGH);
    digitalWrite(2, LOW);
    for (byte i = 0; i < 6; i++) {
        key.keyByte[i] = 0xFF;
    }     
    PCD_Init();
    if ( ! PICC_IsNewCardPresent()) {
        return;
    }
    if ( ! PICC_ReadCardSerial()) {
        return;          
    }
}

UltimateRFID rfid(53, 5);

void setup() {
    rfid.initialize();
}

void loop() {}

Your class then becomes a "flavour" of MFRC522 with additional functionality. It can access all the public functions of the MFRC522 class, since they are now a part of your class. 
Anything you can do with an MFRC522 object you can now do with your object. As well as your extra functions.

35512: <p>I'm having trouble explaining my issue. What I'm doing is creating a library to work easily with the RFID reader/writer RC522 module. I need to create an object of the library MFRC522 in my .cpp file to be able to communticate with the module itself. I want my constructor end up like this:<code>UltimateRFID rfid(53, 5);</code>, the parameters being the slave select and the reset pins, respectively. 
The problem is that I don't know how to make my constructor so that it is within the scope of the functions that require the MFRC522 object to be called. Below's my code.</p>

<pre><code>#include "Arduino.h"
#include "UltimateRFID.h"
#include &lt;MFRC522.h&gt;


MFRC522::MIFARE_Key key;


UltimateRFID::UltimateRFID(int ss, int rst)
{
   MFRC522 mfrc522(ss, rst); //this would be ideal, but how can my functions access the instance?
}


void UltimateRFID::initialize() //sample of a function that uses the MFRC522 object
{
  //digitalWrite(49, HIGH);
  digitalWrite(2, LOW);
  for (byte i = 0; i &lt; 6; i++) {
    key.keyByte[i] = 0xFF;
  }     
  mfrc522.PCD_Init();
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;          
  }

}
</code></pre>

<p>Now comes my header file, although I'm not sure it matters much.</p>

<pre><code>#ifndef UltimateRFID_h
#define UltimateRFID_h

#include "Arduino.h"
#include &lt;MFRC522.h&gt;

class UltimateRFID
{
  public:
    UltimateRFID(int ss, int rst);
    void initialize();
  private:
    MFRC522::MIFARE_Key key;
};

#endif
</code></pre>

<p>Please be patient, it's my first library.</p>
 10794: <pre><code>UltimateRFID::UltimateRFID(int ss, int rst)
{
   MFRC522 mfrc522(ss, rst); //this would be ideal, but how can my functions access the instance?
}
</code></pre>

<p>As you note, that instance would go out of scope immediately. The simplest thing would be to put a <strong>pointer</strong> to the other class in your class definition. Then in your <code>init</code> function do a <code>new</code> to create the instance of the class, passing the appropriate parameters.</p>
 13425: <p>While @Majenko's answer is probably best (I +1'd it), for completeness, here's how to construct a member variable with parameters:</p>

<pre><code>class UltimateRFID {
    public:
    UltimateRFID(int ss, int rst) : mfrc522(ss, rst) {}

    protected:
    MFRC522 mfrc522;
};
</code></pre>

<p>"placement new" is another option:</p>

<pre><code>class UltimateRFID {
    public:
    UltimateRFID(int ss, int rst) {
        new (&amp;mfrc522) MFRC522(ss, rst)
    }

    protected:
    MFRC522 mfrc522;
};
</code></pre>

<p>However, this method calls the default ctor - which may or may not be an issue. This is usually reserved for re-initializing an existing object.</p>

<p>There's also assignment:</p>

<pre><code>class UltimateRFID {
    public:
    UltimateRFID(int ss, int rst) {
        mfrc522 = MFRC522(ss, rst)
    }

    protected:
    MFRC522 mfrc522;
};
</code></pre>

<p>This also calls the default ctor and works best if the class provides <code>operator=</code>.</p>
 4143: <p>Why not have your class just extend the MFRC522 class?</p>

<pre><code>#include &lt;MFRC522.h&gt;

class UltimateRFID : public MFRC522 {
    private:
        MIFARE_Key key;

    public: 
        UltimateRFID(uint8_t ss, uint8_t rst) : MFRC522(ss, rst) {}
        // your other methods
        void initialize();
};

void UltimateRFID::initialize() {
    //digitalWrite(49, HIGH);
    digitalWrite(2, LOW);
    for (byte i = 0; i &lt; 6; i++) {
        key.keyByte[i] = 0xFF;
    }     
    PCD_Init();
    if ( ! PICC_IsNewCardPresent()) {
        return;
    }
    if ( ! PICC_ReadCardSerial()) {
        return;          
    }
}

UltimateRFID rfid(53, 5);

void setup() {
    rfid.initialize();
}

void loop() {}
</code></pre>

<p>Your class then becomes a "flavour" of MFRC522 with additional functionality. It can access all the public functions of the MFRC522 class, since they are now a part of your class. </p>

<p>Anything you can do with an MFRC522 object you can now do with your object. As well as your extra functions.</p>
