mercredi 28 janvier 2015

Implicitly declared function error C++

Ive been having an issue running my C++ file. I keep on getting two errors: definition of implicitly declared. and member declaration not found. im using eclipse Luna and MinGW as my compiler.


**EDIT: here is the exact error:


Multiple markers at this line - Member declaration not found - definition of implicitly-declared 'InsultGenerator::InsultGenerator(const InsultGenerator&)'


Here is the C++ code:



#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "Insultgenerator_0hl14.h"

using namespace std;

FileException::FileException(const string& m) : message(m){}

string& FileException::what(){ return message;}

NumInsultsOutOfBounds::NumInsultsOutOfBounds(const string& m) : message(m){}

string& NumInsultsOutOfBounds::what(){ return message;}

InsultGenerator::InsultGenerator(const InsultGenerator& ) {}

void InsultGenerator::initialize() const{
int cols(0);
string x;

string filename("InsultsSource.txt");
ifstream file(filename.c_str());

if(file.fail()){
throw FileException("File not read.");
}
while(file >> x){

}}

//vector<string> InsultGenerator::talkToMe() const{

// };//end talkToMe

// vector<string> InsultGenerator::generate(const int n) const{

// };//end generate

//int InsultGenerator::generateAndSave(const string filename, const int n) const{

//};//end generateAndSave


Here is the header file:



#ifndef INSULTGENERATOR_0HL14_H_
#define INSULTGENERATOR_0HL14_H_

#include <string>
#include <vector>

using namespace std;

class InsultGenerator{
public:
InsultGenerator(vector<string>);
void initialize() const;
string talkToMe() const;
vector<string> generate(const int) const;
int generateAndSave (const string, const int) const;

private:
vector<string> colA;
vector<string> colB;
vector<string> colC;
};

class FileException{
public:
FileException(const string&);
string& what();
private:
string message;
};

class NumInsultsOutOfBounds{
public:
NumInsultsOutOfBounds(const string &);
string& what();
private:
string message;
};

#endif

Aucun commentaire:

Enregistrer un commentaire