Accessing Node at a pointer address
<p>I've allocated a node an address within an encoding class by going </p>

<pre><code>newnode.zero = &amp;zeronode;
</code></pre>

<p>newnode and zeronode are instances of a node struct, which has a member pointer Node *zero. How do I access that node in a different function in the same class? At the moment I can only seem to get a pointer- by going </p>

<pre><code>Node newnode = *root.zero;
</code></pre>

<p>Here's the whole encoding class as it stands right now;</p>

<pre><code>/**
 * File: encoding.cpp
 * ------------------
 * Place your Encoding class implementation here.
 */

#include "encoding.h"
#include "map.h"
#include "string.h"
#include &lt;string&gt;
#include "strlib.h"
#include "huffman-types.h"
#include "pqueue.h"

using namespace std;

Encoding::Encoding() {

}

Encoding::~Encoding() {
    frequencyTable.clear();
}

void Encoding::compress(ibstream&amp; infile, obstream&amp; outfile) {
    getFrequency(infile);
    compresskey = "";
    foreach(ext_char key in frequencyTable) {

        int freq = frequencyTable.get(key);
        Node newnode;
        newnode.character = key;
        newnode.weight = freq;
        newnode.zero = NULL;
        newnode.one = NULL;

        huffqueue.enqueue(newnode, freq);
        string keystring = integerToString(key);
        string valstring = integerToString(freq);
        compresskey = compresskey + "Key = " + keystring + " " + "Freq = " + valstring + " ";

    }
    buildTree();
    createReferenceTable();

}

void Encoding::decompress(ibstream&amp; infile, obstream&amp; outfile) {

}

void Encoding::getFrequency(ibstream&amp; infile) {

    int ch;

    while((ch = infile.get()) != EOF){
        if(frequencyTable.containsKey(ch)){
            int count;
            count = frequencyTable.get(ch);
            frequencyTable[ch] = ++count;
        }

        else {
            frequencyTable.put(ch, 1);
        }
    }
    frequencyTable.put(PSEUDO_EOF, 1);
}

void Encoding::buildTree() {
    int numnodes = huffqueue.size();
    for (int i = 1; i &lt; numnodes; i++) {
        Node newnode;
        newnode.character = NOT_A_CHAR;
        Node zeronode = huffqueue.extractMin();
        newnode.zero = &amp;zeronode;
        Node onenode = huffqueue.extractMin();
        newnode.one = &amp;onenode;
        int newfreq = zeronode.weight + onenode.weight;
        newnode.weight = newfreq;
        huffqueue.enqueue(newnode, newfreq);
    }
}

void Encoding::createReferenceTable() {
    Node root = huffqueue.extractMin();
    string path = "";

    tracePaths(root, path);

}

void Encoding::tracePaths(Node root, string path) {

    if (!root.character == NOT_A_CHAR) {
        ext_char ch = root.character;
        referenceTable.put(ch, path);
        return;
    }

    for (int i = 0; i &lt; 2; i++) {
        if (i == 0) {
            if (root.zero != NULL) {
                Node newnode = root-&gt;zero;// This is where the problem is


                path = path + "0";
                tracePaths(newnode, path);
            }
        }
        else if (i == 1) {
            if (root.one != NULL) {
                Node newnode = root.one;
                path = path + "1";
                tracePaths(newnode, path);
            }
        }
    }
    return;
}
</code></pre>
