D
djm
hello everyone, im doing a c++ coursework which consists linked lists
and use of classes. but im getting some compilation errors. can some
please help me out.
//this is the header file Definition.h
#ifndef DEFINTION_H
#define DEFINITON_H
#include <string>
using namespace std;
class Definition
{
public:
Definition(); //constructor(intialisation)
~Definition(); //destructor
//setter methods
void setDefinition(string);
void setNext(Definition*);
//getter Methods
string getDefinition();
Definition* getNext();
private:
string definition;
Definition* next;
};
#endif
************************************************************************************************************
//and the cpp file (Definition.cpp)
#include <iostream>
#include <string>
#include "Definition.h"
using namespace std;
Definition:
efinition()
{
definition.clear();
next = NULL;
}
Definition::~Definition()
{
}
void Definition::setDefinition(string d)
{
definition = d;
}
void Definition::setNext(Definition* n)
{
next = n;
}
string Definition::getDefinition()
{
return definition; //*****line 29******
}
Definition* Definition::getDefinition()
{
return next; //*****line 34****
}
************************************************************************************************************
see the problem comes when i try to compile the Definition.cpp file. i
get the following erros
Definition.cpp:34: error: prototype for `Definition*
Definition::getDefinition()
' does not match any in class `Definition'
Definition.cpp:29: error: candidate is: std::string
Definition::getDefinition()
Definition.cpp:34: error: `Definition* Definition::getDefinition()'
and `std::st
ring Definition::getDefinition()' cannot be overloaded
*************************************************************************************************************
ive only done the linked list using integer data types, so i tried the
same coding for string. please forgive me if ive done any stupid
things in the coding.
please help me out
thanks!
and use of classes. but im getting some compilation errors. can some
please help me out.
//this is the header file Definition.h
#ifndef DEFINTION_H
#define DEFINITON_H
#include <string>
using namespace std;
class Definition
{
public:
Definition(); //constructor(intialisation)
~Definition(); //destructor
//setter methods
void setDefinition(string);
void setNext(Definition*);
//getter Methods
string getDefinition();
Definition* getNext();
private:
string definition;
Definition* next;
};
#endif
************************************************************************************************************
//and the cpp file (Definition.cpp)
#include <iostream>
#include <string>
#include "Definition.h"
using namespace std;
Definition:
{
definition.clear();
next = NULL;
}
Definition::~Definition()
{
}
void Definition::setDefinition(string d)
{
definition = d;
}
void Definition::setNext(Definition* n)
{
next = n;
}
string Definition::getDefinition()
{
return definition; //*****line 29******
}
Definition* Definition::getDefinition()
{
return next; //*****line 34****
}
************************************************************************************************************
see the problem comes when i try to compile the Definition.cpp file. i
get the following erros
Definition.cpp:34: error: prototype for `Definition*
Definition::getDefinition()
' does not match any in class `Definition'
Definition.cpp:29: error: candidate is: std::string
Definition::getDefinition()
Definition.cpp:34: error: `Definition* Definition::getDefinition()'
and `std::st
ring Definition::getDefinition()' cannot be overloaded
*************************************************************************************************************
ive only done the linked list using integer data types, so i tried the
same coding for string. please forgive me if ive done any stupid
things in the coding.
please help me out
thanks!