/*
 * pointerInstanceNew.cpp
 * 
 * Author: Deborah R. Fowler
 * Date: Oct 19, 2019
 * 
 * Simple example to show the new function for creating objects
 */


#include <iostream>
using namespace std;

class Muppet
{
    public:
        int energy;
        void talk();
};

void Muppet::talk()
{
    cout << "\nHello, I'm a muppet";
};

int main()
{
        // Previously you saw a class created this way
        Muppet kermit;
        kermit.talk();
        
        // Instead, you can use the new function which returns a pointer to an instance of that class
        Muppet *probin = new Muppet;
        probin->talk();

        // You might say, well how do we get to the value without dereferencing? 
        // C++ provides you with a shortcut
        // ->
        // Functionally equivalent, but messy to type would be
        (*probin).talk();
}

