no member function declared in class

Mar 4, 2009 at 7:03pm
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 Mar 5, 2009 at 5:45am
Mar 4, 2009 at 9:00pm
The error message says "List::print()", not "List::printall()". Are you sure this is the function that's giving you troubles?
Mar 5, 2009 at 2:33am
editted..typo.... the problem is
no `void List::printall()' member function declared in class

T_T ... donno how to solve
Mar 5, 2009 at 3:44am
Are you including the header file in your source file? I don't see that in the post...
Mar 5, 2009 at 4:20am
i do have included the header file in the source file...
Mar 5, 2009 at 4:29am
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 Mar 5, 2009 at 4:29am
Mar 5, 2009 at 5:45am
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?
Mar 5, 2009 at 4:12pm
Post the complete contents of abc.h verbatim.

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