Constructor Error
Jun 17, 2014 at 1:52am UTC
Hello,
I am getting a ISO C++ forbids declaration of Multiset() with no type [-fpermissive] whenever I try to compile my multiset.cpp file which includes multiset.h. Any help would be appreciated. I am using cygwin btw.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
//My h file for class named Multiset
#ifndef MULTISET_H_1234
#define MULTISET_H_1234
#include "items.h"
class Multiset{
public :
MultiSet();
void add_item();
void remove_item();
private :
vector <Item> items;
};
#endif
//My multiset.cpp file
#include <iostream>
#include <string>
#include <vector>
#include "multiset.h"
#include "items.h"
using namespace std;
Multiset::Multiset(){
items.resize(0);
}
void Multiset::add_item(string name, int quantity){
items.push_back(Item(item, quantity));
}
void MultiSet::remove_item(string name){
for (int i = 0; i< items.size(); i++){
if ( name == items[i].get_name()){
items.erase(items[i]);
}
}
}
Jun 17, 2014 at 2:16am UTC
Topic archived. No new replies allowed.