c++ - Set a value of a class from another class -


i'm trying set value of member of class class using snippet. here sample of code i'm trying make work

class { private: int a; public: a() {     = 0; } a(int val) {     = val; } int geta() {     return  a; }  void seta() {     = 290; } };   class b {  b(){};   void setb() {      a;      a.seta(); }  };   int main(){ a; b b; b.setb(); cout << b.geta();  } 

how can make code pint out 290.i prints out 0

in setb a variable temporary destroyed when function returns.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -