mardi 17 mars 2015

How to add elements to a vector


im trying to add elements to a vector in my program. but im not sure if im doin it right. so far what i have below does not work. i get an error that says error LNK2019: unresolved external symbol "public: __thiscall MySet::MySet(void)" (??0MySet@@QAE@XZ) referenced in function _main



#include <iostream>
#include <map>
#include <vector>

using namespace std;

class MySet{


public:
vector<int> elements;
MySet();
void addElement(int value);
int removeElement(int index);
int sum();
int size();
};




void MySet::addElement(int value){
elements.push_back(value);

}
int main(int argc, char *argv[]){
int value;
MySet set;
cout << "Enter your numbers " << endl;
cin >> value;
while(value != -1){
set.addElement(value);
}

system("PAUSE");
}



Aucun commentaire:

Enregistrer un commentaire