Please help me with my problem in algorithm coding.. the error says no matching function call .. i attach the picture in this thread hoping u help me :)

Recommended Answers

Your function is defined as

int BinaryTree::getLeafCount(struct node *node) {

Notice the node* parameter...
But your call is

b.getLeafCount();

Notice the lack of an argument...

Basically, because you didn't call it properly, you've unintentionally overloaded the function, but you don't have a …

Jump to Post

All 4 Replies

Your function is defined as

int BinaryTree::getLeafCount(struct node *node) {

Notice the node* parameter...
But your call is

b.getLeafCount();

Notice the lack of an argument...

Basically, because you didn't call it properly, you've unintentionally overloaded the function, but you don't have a definition/implementation of the overloaded version.

>> Basically, because you didn't call it properly, you've unintentionally overloaded the function, but you don't have a definition/implementation of the overloaded version.
i think you'r wrong about that, you cant declare a function as this

b.getLeafCount();

you must use :: operator to tell the compiler that it belongs to a class, not the '.' operator

>> Basically, because you didn't call it properly, you've unintentionally overloaded the function, but you don't have a definition/implementation of the overloaded version.
i think you'r wrong about that, you cant declare a function as this

b.getLeafCount();

you must use :: operator to tell the compiler that it belongs to a class, not the '.' operator

No, he's completely right. b.getLeafCount(); is not a declaration. It's a call to the getLeafCount(); method in the class named b. If he had used BinaryTree::getLeafCount() in the correct place in the code, he would have an overloaded function.

you're missing the parameter.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.