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

C++ konstruktor tablic i vektor.

Ostatnio zmodyfikowano 2014-10-18 14:49
Autor Wiadomość
Jacahehe
Temat założony przez niniejszego użytkownika
C++ konstruktor tablic i vektor.
» 2014-10-18 13:59:04
Witam! Chcę zrobić na wzór z jednej lekcji konstruktor do dość sporej klasy, a pózniej zamknąć go w std::vector. Wszystko super, tylko jest mały problem- nie mam pojecia jak wrzucic w ten konstruktor tablice.

C/C++
class hero
{
    sf::Vector2f vhead; //
    sf::Vector2f vbody; //
    sf::Vector2f vlegs; // positions x and y
    sf::Vector2f vshield; //
    sf::Vector2f vweapon; //
   
    int self_animation_time; // animation time (120)
    bool bool_self_animation; // is hero animated?
    int frame_number; // with frame is currently splited on the screen
   
    int tab_id[ 4 ]; // whitch id of head(0), body(1), legs(2), shield(3) and weapon(4) has hero
    int tab_image_h[ 4 ]; // high of simple frame (head(0), body(1), legs(2), shield(3), weapon(4))
    int tab_image_w[ 4 ]; // width of simple frame (head(0), body(1), legs(2), shield(3), weapon(4))
   
    float speed; // hero speed
    int stats[ 8 ]; // hero statistics (lvl(0), hp(1), mp(2), attack(3), magic attack(4), defence(5), magic defence(6), agility(7), luck(8))
    long long exp; //hero experience
   
    hero( sf::Vector2f Cvhead, sf::Vector2f Cvbody, sf::Vector2f Cvlegs, //
    sf::Vector2f Cvshield, sf::Vector2f Cvweapon, int Cself_animation_time, //
    bool Cbool_self_animation, int Cframe_number, int Ctab_id[ 4 ], // constructor
    int Ctab_image_h[ 4 ], int Ctab_image_w[ 4 ], float speed, //
    int stats[ 8 ], long long exp ); //
   
   
    void split_n_animate_hero(); // draw, rotate and, if its necessary, anime hero
    void move_hero(); //update hero position, detects collisions
    void hero_action(); //attack, talk, cut wood, whatever...
};

hero::hero( sf::Vector2f Cvhead, sf::Vector2f Cvbody, sf::Vector2f Cvlegs, //
sf::Vector2f Cvshield, sf::Vector2f Cvweapon, int Cself_animation_time, //
bool Cbool_self_animation, int Cframe_number, int Ctab_id[ 4 ], // constructor
int Ctab_image_h[ 4 ], int Ctab_image_w[ 4 ], float speed, //
int stats[ 8 ], long long exp ) //

    : vhead( Cvhead )
     , vbody( Cvbody )
     , vlegs( Cvhead )
     , vshield( Cvshield )
     , vweapon( Cvweapon )
     , self_animation_time( Cself_animation_time )
     , bool_self_animation( Cbool_self_animation )
     , frame_number( Cframe_number )
     , tab_id[ 4 ]( Ctab_id ) //TUTAJ jest problem :(
     ,

Ma ktoś pomysł jak to zrobić?
P-118761
Monika90
» 2014-10-18 14:18:24
W jaki sposób chciałbyś konstruktor klasy hero wywoływać?
P-118764
Jacahehe
Temat założony przez niniejszego użytkownika
» 2014-10-18 14:49:37
W sumie w zaden :) Potrzebny mi tylko do tego zeby to wrzucic do vectora tak jak jest to w temacie http://cpp0x.pl/kursy​/Kurs-STL-C++​/Kontener-tablicy-std-vector​/119 a dokladnie w dziale "Tworzenie tablicy obiektow własnej klasy"
P-118769
« 1 »
  Strona 1 z 1