This isn't visual basic coding... probably C++
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.
This isn't visual basic coding... probably C++
The function Attack() decreases the health of the character by the value of Atk
for example
More clearly :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
Attack functions is just :
Hope you get itCode:T3K.hp = T3K.hp - T3K.atk; //or T3K.hp = T3K.hp - 1;
Last edited by pedbera; 07-02-2013 at 06:02 PM.