no member function declared in class

Any1 can explain to me what's wrong? Do i make serious mistake in this? If yes, please explain more clearly (i am really new to C++)

error shown:"no `void List::printall()' member function declared in class"

//below is header file abc.h
class List
{ //some code not shown
void printall();
};

//below is implementation file abc.cpp

#include "abc.h"
#include <iostream>
using namespace std;

void List::printall() //to printout all the element in a list
{
if (head==NULL)
cout<< "nothing in the list!" << endl;
else
{
Node *current = head;
while(current!=NULL)
{
cout << current->item <<", ";
current=current->next;
}
cout<< endl;
}
}

int main()
{
List b;
b.add(1);
b.printall();
return 0;
}

I try to compile with command g++ -Wall dd.cpp (with header file seperated with implementation file)
then "no `void List::printall()' member function declared in class" is shown

But, when i replace the #include "abc.h" with the code that i defined in the abc.h file
no error is shown. What is happening?

Last edited on
The error message says "List::print()", not "List::printall()". Are you sure this is the function that's giving you troubles?
editted..typo.... the problem is
no `void List::printall()' member function declared in class

T_T ... donno how to solve
Are you including the header file in your source file? I don't see that in the post...
i do have included the header file in the source file...
Only thing I can think of is a slight spelling error like printal1 (with a '1' (one)) instead of printall (with a lowercase L). OR this is a byproduct of another error and the other error is your real problem. Do you get any other compiler errors?

Nothing you've shown so far indicates it wouldn't be working. It all looks good to me.
Last edited on
I try to compile with command g++ -Wall dd.cpp (with header file seperated with implementation file)
then "no `void List::printall()' member function declared in class" is shown

But, when i replace the #include "abc.h" with the code that i defined in the abc.h file
no error is shown. What is happening?
Post the complete contents of abc.h verbatim.

Sounds like an include guard problem.
Topic archived. No new replies allowed.