Use of 'this' pointer to delete
===

I'm working on a project for school.
It simulates students buying soda from a vending machine.
There is a class called Card that is a member in the class Student.
That is,

Every student has a card, which makes sense.

    class Student {
    public:
    Student( Office &cardOffice );
    ~Student();
    bool action();
    private:
    Office* studentOffice;	        // stores cardoffice.
    Card* card;			        // stores card
    
    };

A student's card is created via a call to the studentOffice.create() function. That function returns a card.

    Card* Office::create( int id, int money ) {
    Card* card = new Card();
    card->id = id;
    card->amount = money;
    return card;
    }

Students call a function in the class VendingMachine called action() to buy food. The buy function in VendingMachine returns a type enumeration from the Status enum in the VendingMachine class.

There is a prng, generating a random number from 0 - 9. The assignment says that there is a 1 in 10 chance of the student's card being destroyed. And he/she will obtain a new one the next time student.action() is called.

    VendingMachine::Status VendingMachine::buy(Card* &card)
    {
    	if(prng(9) == 0) // generates number from 0-9
    	{
    		delete card;
    	}
    	return status;
    }

Originally, I was thinking to check in the student's action() routine to see if the card is NULL, (if it was deleted), and create a new one if that happens. However, I know the code gets to the delete card portion, but it fails when checking that the card is NULL. So that must mean the card is not null, which means the delete didn't work.

But I also noticed that the card that is passed in is of type

    Card* &card

I was then thinking of using a call with the "this" pointer as I know the student is what called this routine and "this" will point to the object that called it according to:

It points to the object for which the member function is called.
from http://msdn.microsoft.com/en-us/library/y0dddwwd(v=vs.80).aspx

However, if I do:

	if(prng(9) == 0)
	{
		delete this->card;
	}

it gives me this error when running my makefile:

error: class VendingMachine has no member named card

Which is true, it doesn't. Is the compiler assuming that a VendingMachine will call this method? Because the student does. 

1. Maybe I should add a student to every vending machine and delete the card from that member instead? I would strongly prefer not doing this, as there are multiple students and that would mean I need to store them all if they are assigned to this vending machine. Although, if it comes down to it, I could do it this way.

2. If the delete card happened, but the card is not NULL, what exactly went down when I deleted the card?

3. How would I go about deleting the card?

Thanks!