Jag håller på med min c++ läxa, men när jag kompilar programmet så fpr jag ett obegripligt errormedelande: Visa spoiler
error: no matching function for call to `std::vector<std::string, std::allocator<std::string> >::push_back(ord&)
Det ända jag förstår är att vektorn och structen strular, men jag vet även att detta ska funka (de gör den i skolans datorer). Jag använder GCC och codeblocks, kan det vara så att de är anledningen bakom de hela?
Tack i förhand!
Koden:Visa spoiler
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
using namespace std;
struct ord
{
string word;
string forklaring;
};
vector<string> words;
void wordlist() {
ord temp;
if (!words.empty())
{
words.clear();
}
system("cls");
cout << "End input by typing #.\n";
cout << "\nNew word:";
getline(cin, temp.word);
while ( temp.word != "#")
{
cout << "Definition:";
getline(cin, temp.forklaring);
words.push_back(temp);
cout << "New word:";
getline(cin, temp.word);
}
}
#include <vector>
#include <fstream>
#include <string>
using namespace std;
struct ord
{
string word;
string forklaring;
};
vector<string> words;
void wordlist() {
ord temp;
if (!words.empty())
{
words.clear();
}
system("cls");
cout << "End input by typing #.\n";
cout << "\nNew word:";
getline(cin, temp.word);
while ( temp.word != "#")
{
cout << "Definition:";
getline(cin, temp.forklaring);
words.push_back(temp);
cout << "New word:";
getline(cin, temp.word);
}
}