Can't get compiler to let me be terrible

closed account (Lv0f92yv)
Hi all, I want to try to do some funky terribleness to allow user to call a function with no parameters.

Basically, the compiler errors on this:

void printlist(Node* c = NULL, int a = 0xFF);

In case you're wondering how terrible it gets,

1
2
3
4
5
6
7
void printlist(Node* c = NULL, int a = 0xFF) {
    if (a == 0xFF) //this is my bad way of doing something bad. deal with it.
        c = t->root;
    printlist(c->left, 1);
    cout << "word: " << c->data << "\n";
    printlist(c->right, 1);
}


The error:

1
2
3
main.cpp: In function 'void printlist(Node*, int)':
main.cpp:127:44: error: default argument given for parameter 1 of 'void printlist(Node*, int)'
main.cpp:29:6: error: after previous specification in 'void printlist(Node*, int)'


I'm using netbeans with minSYS and minGW. Is this sort of thing simply not allowed because it is so terrible?
Last edited on
closed account (Lv0f92yv)
Sorry... failblog entry for me.

Fix was simple - use proper syntax (don't do the assignment in the definition... poof)

Also - there was no base case for that function.
Last edited on
Topic archived. No new replies allowed.