I don't think I've learned how to access all of an array of structs (that have pointers) through a member function. So, I'm trying to output all of the array's struct pointer to data , but I cant seem to figure out how to make the function call. So, how would I go about fixing this problem? thnx
main.cpp
Code:
#include <iostream>
#include "func.h"
using namespace std;
int main(int argc, char * argv[])
{
int n = atoi(argv[1]);
utree * forest = new utree[n];
forest.printArray(); // NOT the right call :/
return 0;
}
func.h
Code:
struct node
{
int data;
node * parent;
node();
node ( int, node * );
};
class utree
{
public:
void printArray(int);
int find(int);
private:
node * root;
};
func.cpp
Code:
#include "func.h"
#include <iostream>
using namespace std;
/*Construtors*/
node::node(){data = -1; parent = NULL;}
node::node(int n, node * link){data = n; parent = link;}
void utree::printArray(int n)
{
for(int i = 0; i < n; i++)
{
cout << this[i].root->data;
}
}