Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Problem z utworzeniem obiektu

Ostatnio zmodyfikowano 2014-05-09 00:51
Autor Wiadomość
Acarin1995
Temat założony przez niniejszego użytkownika
Problem z utworzeniem obiektu
» 2014-05-08 22:00:49
C/C++
//Przedmiot.hpp
#ifndef PRZEDMIOT_hpp
#define PRZEDMIOT_hpp
#include "main.hpp"
class CPrzedmiot
{
public:
    string nazwa;
    int atakMin;
    int atakMax;
    int punktyPancerza;
    int typ;
    int wartosc;
    vector < CPrzedmiot *> zbiorPrzedmiotow;
    CPrzedmiot( string nazwa, int atakMin, int atakMax, int punktyPancerza, int typ, int wartosc );
    int wczytajPrzedmioty();
   
};

#endif

//Przedmiot.hpp
#include "Przedmiot.hpp"
CPrzedmiot::CPrzedmiot( string nazwa_, int atakMin_, int atakMax_, int punktyPancerza_, int typ_, int wartosc_ )
{
    nazwa = nazwa_;
    atakMin = atakMin_;
    atakMax = atakMax_;
    typ = typ_;
    wartosc = wartosc_;
    punktyPancerza = punktyPancerza_;
}
int CPrzedmiot::wczytajPrzedmioty()
{
    //balablabla
}

//main.cpp

#include "main.hpp"
#include "Przedmiot.hpp
int main()
{
    CPrzedmiot Przedmiot_;
    Przedmiot_.wczytajPrzedmioty();
   
}
a oto problem:

-------------- Build: Release in Nevermore (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -fexceptions -O2  -c "I:\Programowanie\Nevermore\Nevermore v.0.0.7\main.cpp" -o obj\Release\main.o
I:\Programowanie\Nevermore\Nevermore v.0.0.7\main.cpp: In function 'int main()':
I:\Programowanie\Nevermore\Nevermore v.0.0.7\main.cpp:19:13: error: no matching function for call to 'CPrzedmiot::CPrzedmiot()'
I:\Programowanie\Nevermore\Nevermore v.0.0.7\main.cpp:19:13: note: candidates are:
In file included from I:\Programowanie\Nevermore\Nevermore v.0.0.7\Postac.hpp:5:0,
                 from I:\Programowanie\Nevermore\Nevermore v.0.0.7\main.cpp:2:
I:\Programowanie\Nevermore\Nevermore v.0.0.7\Przedmiot.hpp:15:10: note: CPrzedmiot::CPrzedmiot(std::string, int, int, int, int, int)
I:\Programowanie\Nevermore\Nevermore v.0.0.7\Przedmiot.hpp:15:10: note:   candidate expects 6 arguments, 0 provided
I:\Programowanie\Nevermore\Nevermore v.0.0.7\Przedmiot.hpp:5:7: note: CPrzedmiot::CPrzedmiot(const CPrzedmiot&)
I:\Programowanie\Nevermore\Nevermore v.0.0.7\Przedmiot.hpp:5:7: note:   candidate expects 1 argument, 0 provided
P-109530
pekfos
» 2014-05-08 22:02:52
Nie możesz utworzyć obiektu CPrzedmiot bez podania argumentów konstruktora.
P-109531
michal11
» 2014-05-08 23:35:03
Przepraszam bardzo, ale jaki masz problem z przeczytaniem i zrozumieniem błędu który ci wyskoczył ? Przecież tam jest wszystko napisane.

error: no matching function for call to 'CPrzedmiot::CPrzedmiot()'

Co jest tutaj nie jasne ?
P-109532
libed
» 2014-05-09 00:51:57
Jesteś pewny, że klasa Przedmiot potrzebuje takich składowych jakie podałeś?
Poza tym klasa Przedmiot nie jest najlepszym miejscem do trzymania wektora wskaźników na inne Przedmioty, bo nie wiadomo czy obiekty tej klasy reprezentują konkretny przedmiot czy kolekcję przedmiotów.
P-109535
« 1 »
  Strona 1 z 1