Я уже проверял другие подобные вопросы, но я до сих пор не могу избавиться от проблемы. Я попытался использовать эту функцию как публичную, так и частную.
У меня есть функции removeALL в моем классе:
Объявление класса
#ifndef STRINGSET_H
#define STRINGSET_H
#include <iostream>
#include <string>
#include "StringNode.h"
using namespace std;
class StringSet
{
public:
// Constructor: creates an empty set.
StringSet();
// Destructor.
~StringSet();
// Returns the number of elements in the set.
int size();
// Inserts 'element' into the set. If 'element' is contained in the
// set, this operation has no effect.
void insert(string element);
// Removes 'element' from the set. If 'element' is not in the set, this
// operation has no effect.
void remove(string element);
// Returns true if and only if 'element' is a member of the set.
bool contains(string element);
// A friend function for writing the contents of the set to an output stream.
friend ostream& operator <<(ostream& outs, const StringSet& set);
private:
void removeAll();
int fixing (string element);
NodePtr head; // pointer to the head of the linked list
};
#endif // STRINGSET_H
Но когда я пытаюсь создать функцию в файле cpp, я получаю ошибку: no 'void StringSet :: removeALL()' функции-члены, объявленные в классе 'StringSet'
Функция RemoveALL и заголовок в cpp
#include <iostream>
#include <string>
#include "StringSet.h"
using namespace std;
void StringSet::removeALL()
{
if(head == NULL){
cout << "The list is empty" << endl;
return;
}
while (NodePtr temp = head)
{
head = temp->getLink();
delete temp;
}
}
int StringSet::fixing(string element)
{
int temp = 0;
if(((element[0] == 'n') || (element[0] == 'N')) && ((element[1] == 'o') || (element[1] == 'O'))
&& ((element[2] == 't') || (element[2] == 'T')))
{
element.erase(0,3);
remove(element);
element.clear();
temp = 1;
return temp;
}
else return temp;
}
у кого-нибудь есть решение? Заранее спасибо!
C++ чувствителен к регистру. removeAll
и removeALL
- это разные вещи.