Hej! Mam pewien problem.
Prosta aplikacja ma 3 pliki
main.cpp
#include <iostream>
#include <string>
#include "rachunek.h"
using namespace std;
int main()
{
TRachunek ror("Alicja", "Nowak", 0);
ror.Wplata(400);
ror.NaliczOdsetki(2.3);
ror.Wyswietl();
cout << "Witaj!" << endl;
return 0;
}
rachunek.cpp
#include <iostream>
#include <string>
#include "rachunek.h"
// deklarujemy przestrzen nazw
using namespace std;
// konstruktor z parametrami
TRachunek::TRachunek(string _imie, string _nazwisko, int _saldo)
{
imie = _imie;
nazwisko = _nazwisko;
saldo = _saldo;
debet = 0;
}
// funkcja zwracajaca stan konta
int TRachunek::PodajStanKonta()
{
return saldo + debet;
}
// funkcja powodujaca wplate na konto
void TRachunek::Wplata(int wplata)
{
/kod
}
bool TRachunek::Wyplata(int kwota)
{
// kod
}
bool TRachunek::CzyDebet()
{
if (saldo < 0)
{
return true;
}
else
{
return false;
}
}
bool TRachunek::Przelew(TRachunek rachunek, int kwota)
{
// jakis tam kod
}
double TRachunek::NaliczOdsetki(double wysokosc_oprocentowania)
{
// jakis tam kod
}
void TRachunek::Wyswietl()
{
cout << "Imie : " << imie << "| Nazwisko : " << nazwisko << endl;
cout << "Saldo : " << saldo << endl;
cout << "Debet : " << debet << endl;
cout <<
}
rachunek.h
#ifndef RACHUNEK_H_INCLUDED
#define RACHUNEK_H_INCLUDED
#include <iostream>
#include <string>
// deklarujemy przestrzeñ nazw
using namespace std;
class TRachunek
{
public:
TRachunek(string _imie, string _nazwisko, int _saldo);
int PodajStanKonta();
void Wplata(int wplata);
bool Wyplata(int kwota);
bool CzyDebet();
bool Przelew(TRachunek rachunek, int kwota);
double NaliczOdsetki(double wysokosc_oprocentowania);
void Wyswietl();
private:
string imie, nazwisko;
int saldo;
int debet;
};
#endif // RACHUNEK_H_INCLUDED
Kompiluje sie ok ale...
obj\Debug\main.o||In function `main':|
D:\Dokumenty\ZadaniaCPP\Rachunek\main.cpp|10|undefined reference to `TRachunek::TRachunek(std::string, std::string, int)'|
D:\Dokumenty\ZadaniaCPP\Rachunek\main.cpp|11|undefined reference to `TRachunek::Wplata(int)'|
D:\Dokumenty\ZadaniaCPP\Rachunek\main.cpp|12|undefined reference to `TRachunek::NaliczOdsetki(double)'|
D:\Dokumenty\ZadaniaCPP\Rachunek\main.cpp|13|undefined reference to `TRachunek::Wyswietl()'|
||=== Build finished: 4 errors, 0 warnings ===|
Taki blad wyrzuca linker.
Uzywam Code::Blocks 10.5
kompilator MinGW
Co to moze byc??