Noob question about a use a friend class
Code:
#include <iostream>
using namespace std;
class IntNode {
private:
int x;
IntNode* p;
public:
IntNode( int n = 0, IntNode* volgende = NULL) : x (n), p(volgende)
{}
friend class Lijst;
};
class Lijst{
private:
IntNode * head;
public:
Lijst() : head ( NULL ){}
void voegToe(int x){
head = new IntNode(x,head);
}
void print() {
IntNode* wijzer = head;
while (wijzer != NULL) {
cout<< wijzer -> x << endl;
wijzer = wijzer -> p;
}
cout << endl;
}
void buildUp(int getal){
int i=0;
int hulp = getal;
int helpInt;
char buffer [255];
snprintf (buffer, 255, "%d", hulp);
while(buffer[i] != '\0'){
if (buffer[i] > 47 && buffer[i] < 58){
helpInt = buffer[i]-48;
buffer[i];
i++;
}
head = new IntNode(helpInt,head);
}
}
Lijst reverse(){ // not processed
Lijst* hulpLijst;
return *hulpLijst;
}
bool operator > (Lijst lijst2){ //also not processed
bool boolHulp = true;
return boolHulp;
}
};
int main () {
Lijst lijst1, lijst2;
lijst1.print();
lijst1.buildUp(3456);
lijst1.print();
lijst2.Lijst.reverse(); // has to look 6543
lijst2.print();
// I have to use it like this lijst2.????.reverse();
// I know I can use this one lijst2.reverse(lijst2)
return 0;
}