Results 1 to 3 of 3
  1. #1
    meromarololo2's Avatar
    Join Date
    May 2013
    Gender
    male
    Posts
    23
    Reputation
    10
    Thanks
    2

    GUYS IM GOIN MAD CUZ OF THIS CODE

    Tomorrow is my last day to be understanding everything about C++, but this one.. i just dont get it..

    #include <iostream>
    using namespace std;

    class Character
    {
    public:
    double HP,Atk;

    void attack(Character &Enemy)
    {
    Enemy.HP -=Atk;
    }
    Character()
    {
    HP=5;
    Atk=1;
    }
    };
    int main()
    {

    Character SMART, dumb;

    cout<<"SMART HP "<<SMART.HP<<endl;
    cout<<"dumb HP "<<dumb.HP<<endl;
    dumb.attack(SMART); // THIS ONE GUYS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    cout<<endl<<endl<<endl;
    cout<<"SMART HP "<<SMART.HP<<endl;
    cout<<"dumb HP "<<dumb.HP<<endl;
    cin.get();
    return 0;

    }

    So if some1 could help me and explain every word of it..
    copy and paste in ur visual basic so u understand better.
    Last edited by meromarololo2; 07-02-2013 at 01:49 PM.

  2. #2
    unSatisfied's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Location
    My House
    Posts
    104
    Reputation
    10
    Thanks
    8
    My Mood
    Stressed
    This isn't visual basic coding... probably C++

  3. #3
    pedbera's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    261
    Reputation
    15
    Thanks
    43
    My Mood
    Happy
    The function Attack() decreases the health of the character by the value of Atk

    for example

    Code:
    Character T3K;
    Cout << T3K.HP <<; // This should print 5 as you wrote, 5 is the max health
    T3K.attack;        // This should Damage the character's health therefore T3K.HP will decrease by 1
    Cout << T3K.HP <<; // This should print 4
    More clearly :
    Attack functions is just :
    Code:
    T3K.hp = T3K.hp - T3K.atk;
    //or
    T3K.hp = T3K.hp - 1;
    Hope you get it
    Last edited by pedbera; 07-02-2013 at 06:02 PM.

Similar Threads

  1. [Help Request] GUYS IM GOIN MAD CUZ OF THIS CODE
    By meromarololo2 in forum C++/C Programming
    Replies: 6
    Last Post: 07-02-2013, 02:28 PM
  2. [Help] GUYS IM GOIN MAD
    By meromarololo in forum C++/C Programming
    Replies: 3
    Last Post: 07-01-2013, 06:23 AM
  3. Whats wrong with this code ?
    By bohnenbong in forum WarRock - International Hacks
    Replies: 7
    Last Post: 10-26-2007, 06:57 AM
  4. tell me what is rong in this code!!
    By boom.. in forum WarRock - International Hacks
    Replies: 3
    Last Post: 06-07-2007, 06:53 PM
  5. I need someone to write this code here
    By EyalZamir in forum WarRock Korea Hacks
    Replies: 2
    Last Post: 05-14-2007, 06:11 AM