I need some help here, could you tell me how I can get p2 variable content? I can get variables through t1 and p1 but I want to use p2 to get health and mana values.
#include <iostream>
using namespace std;
class Mage{
public:
int health;
int mana;
Mage(int health, int mana){
this->health = health;
this->mana = mana;
}
};
int main(){
Mage t1 = Mage(1,1);
Mage *p1 = &t1;
Mage **p2 = &p1;
cout << t1.health << endl;
cout << p1->health << endl;
cout << "how to print variable content with p2?" << endl;
return 0;
}
(*p2)->health?std::vectorofstd::unique_ptr,(*it)->foo()needs 2 levels of indirection, there is no other way around it.