Hi there
I'm trying to learn how to do classes in C++ while working on a project. I have some code (below) which fails to compile with the error (below)
Any help would be appreciated.
Many thanks
packageType.cc: In static member function ‘static packageType* packageType::fromString(std::string)’:
packageType.cc:20: error: request for member ‘toString’ in ‘packageType::NOT_IMPORTANT’, which is of non-class type ‘const packageType* ()()’
packageType.cc:20: error: cannot convert ‘const packageType* (*)()’ to ‘packageType*’ in return
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
using namespace std;
class packageType{
private:
packageType(string name){}
~packageType(){}
string name;
public:
const static packageType* NOT_IMPORTANT(){return new packageType("Not Important");};
const static packageType* IMPORTANT(){return new packageType("Important");};
const static packageType* TESTING(){return new packageType("Testing");};
string toString();
static packageType* fromString(string type){
if(NOT_IMPORTANT->toString().compare(type) == 0){return NOT_IMPORTANT;}
}
};
string packageType::toString(){
return name;
}
int main(void){
return(0);
}