im not sure if you addressed this issue yet, but what if you want to use differnt integers from differtnt classes, in one expression? like for battle damage formulas
Player_attack/enemy_defense=total damage.
how would i get them to interact if they are in differnt scopes?
through making member functions that provide an interface to the classes' member variables. for example;
int total = john.getValue() + bob.getValue();
ofcourse each case will need its own implementation of this idea. sometimes youl return the variable by value, other times by reference. sometimes youl decide it makes sense for some class to do the job so youl just john.doJob(bob.getValue()) or vice versa...
I made this class and it works but I think it should crash because I am defining the same variable twice, once in setname function and once in the constructor function. Why is it correct?
I am sorry it is a bit messy.
class gradebook {
public:
gradebook(string name){ setname(name);}
void setname(string name){ nameofcourse= name;}
string getname(){return nameofcourse;}
void display(){cout << " the name of the object is " << getname() << endl; }
no it is no problem that both the constuctor and setname define a variable (as parameter) with same name. Namely, 'name' :)
you can make life slightly easier by just assigning 'name' to 'nameofcourse' in the constructor, instead of calling setname. and just cout << nameofcourse instead of calling getname.
otherwise, i dont really see a problem anywhere... maybe im just too tired and not looking careful enough :/
I thought since I once declare string name in the constructor function, it exists in the class, therefore when I again declare string name in the setname function they should collide and the program should crash, and of all my wonders this doesnt happen.
you know... the resolution isn't as good as the last one (the standard one)... can't you do something to replace it, or make it better ? good vid btw !
i dont understand myself. i updated this video twice with the very same settings as videos 42updated 43updated 44updated etc but unlike these aforementioned, this one wont turn into high quality...
the phrase is "out IN the open." : )
Villanovagypsy 5 months ago
what do you think about the new "D" language will you ever learn it?
will you ever put a lesson series on about it?
are there compilers out for D right now?
101abob 1 year ago
@101abob Haha, Im done that and Im learning D++ and Objective-D
dagr8master 7 months ago
You say "Class" a lot in this tutorial, what is that in English? I don't really understand that..
BufferOverflowAttack 2 years ago
did you watch all previous videos? it should be clear if you did
antiRTFM 2 years ago 16
@BufferOverflowAttack
LOL it is in english. Its something you use to combine a whole bunch of things. I cant really explain it well so go back to the other videos
TheFierceGaming 1 year ago
@BufferOverflowAttack WTFV (watch the f'ing videos) lol. I know the question was asked a long time ago
MrMegabucks15 1 year ago
To understand what the word class in English means I would use and online dictionary. As for programming there is a video to teach what class means.
Villanovagypsy 5 months ago
What screen recorder do you use?
HackedVision 2 years ago
CamStudio 2.5
antiRTFM 2 years ago
Thank you.
HackedVision 2 years ago
im not sure if you addressed this issue yet, but what if you want to use differnt integers from differtnt classes, in one expression? like for battle damage formulas
Player_attack/enemy_defense=total damage.
how would i get them to interact if they are in differnt scopes?
ZayLong 2 years ago
through making member functions that provide an interface to the classes' member variables. for example;
int total = john.getValue() + bob.getValue();
ofcourse each case will need its own implementation of this idea. sometimes youl return the variable by value, other times by reference. sometimes youl decide it makes sense for some class to do the job so youl just john.doJob(bob.getValue()) or vice versa...
antiRTFM 2 years ago
class monster
{ public: monster( )
{ int damage = 10
} int getdamage( ) { return damage; } private: int damage;
};
int main ( )
{ monster ghost;
int a = ghost.getdamage( )
sproutamation 2 years ago
Nice
alexrocksandpearls 2 years ago
I made this class and it works but I think it should crash because I am defining the same variable twice, once in setname function and once in the constructor function. Why is it correct?
I am sorry it is a bit messy.
class gradebook {
public:
gradebook(string name){ setname(name);}
void setname(string name){ nameofcourse= name;}
string getname(){return nameofcourse;}
void display(){cout << " the name of the object is " << getname() << endl; }
private: string nameofcourse;
};
danielghofrani 3 years ago
no it is no problem that both the constuctor and setname define a variable (as parameter) with same name. Namely, 'name' :)
you can make life slightly easier by just assigning 'name' to 'nameofcourse' in the constructor, instead of calling setname. and just cout << nameofcourse instead of calling getname.
otherwise, i dont really see a problem anywhere... maybe im just too tired and not looking careful enough :/
antiRTFM 3 years ago
I thought since I once declare string name in the constructor function, it exists in the class, therefore when I again declare string name in the setname function they should collide and the program should crash, and of all my wonders this doesnt happen.
danielghofrani 3 years ago
i understood everything, but it's still kinda anoying to not be able to see what you're writting...
lambda30 3 years ago
you know... the resolution isn't as good as the last one (the standard one)... can't you do something to replace it, or make it better ? good vid btw !
lambda30 3 years ago
i dont understand myself. i updated this video twice with the very same settings as videos 42updated 43updated 44updated etc but unlike these aforementioned, this one wont turn into high quality...
antiRTFM 3 years ago