Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm having an issue compiling my C++ file. This is the error I get:

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

I'm using MinGW as my compiler.

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
319 views
Welcome To Ask or Share your Answers For Others

1 Answer

You are implementing InsultGenerator's copy-constructor although you haven't declared it.

Add InsultGenerator(const InsultGenerator& ); to your InsultGenerator class. Like so:

class InsultGenerator
{
public:
    InsultGenerator(vector<string>); // also better remove that one since I don't
                                     // think you have implemented it

    InsultGenerator(const InsultGenerator &); // here
    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;
};

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...