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?
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.
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?