Witam
No i pojawił się kolejny problem.
Otóż mam już prawie gotowy program tylko chcę go napisać na klasach.
Niby zrobiłem jedną klasę ale niestety wywala mi taki oto błąd.
http://img651.imageshack.us/img651/5126/29731491.png
Mam nadzieję, że będzie ktoś mi w stanie pomóc.
A oto moje pliki z klasą.
banknoty.cpp
#include "banknoty.h"
#include <iostream>
#include <fstream>
#include <map>
#include <limits>
#include <vector>
using namespace std;
void banknoty::alg(int, map<int, int>&)
{
while(true)
{
ifstream iFile("./dane/banknoty.txt");
int a, b;
map<int, int>mapa;
while(iFile >> a >>b )
mapa.insert(pair<int, int>(a, b));
map<int, int>::iterator it = mapa.begin();
for(;it != mapa.end(); ++it)
cout << (*it).first << " " << (*it).second << "\n";
int n;
cout << "ile wyplacic? : ";
cin >> n;
alg(n, mapa);
it = mapa.begin();
ofstream oFile("./dane/banknoty.txt");
for(;it != mapa.end(); ++it)
oFile << (*it).first << " " << (*it).second<<"\n";
oFile.close();
system("pause");
}
}
banknoty.h
#pragma once
#include <map>
#include <limits>
#include <vector>
using namespace std;
class banknoty
{
public:
void banknoty::alg( int v, map<int, int> &m )
{
map<int, int>::reverse_iterator it = m.rbegin();
for(; it != m.rend(); ++it)
{
while((*it).first <= v && (*it).second > 0)
{
v -= (*it).first;
(*it).second--;
}
}
}
};