I noticed when practicing classes that when calling functions within a class I can either use the resolution scope operator or leave that off, and my program still works. Is it better to include it or not? Example down below calls the introduction function twice, which one to keep?
Also after seeing your example it just dawned on me that std::cout is also a scope resolution (if you want to avoid using namespace std), calling upon the standard library I think.
this is a pointer that points to the object to which you send the message.
For example if you do game.run();, inside `.run()' this would point to `game'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
class foo{
public:
virtualdouble value(){
return 42;
}
virtual ~foo() = default;
};
class bar: public foo{
double bonus;
public:
virtualdouble value(){
return foo::value() * this->bonus;
}
}
I know you want to avoid global things when possible, it's just that typing a lot of std::cout all over the place takes extra time. I can always take it out of global and make it local or something.