samedi 22 octobre 2016

How to access variables in different class from other class

x cannot be static

I'd like to have

class A{
  static std::vector<C> vec_ca;
public:
  int x = 6;
`};
class B{
 std::vector<C> vec_cb;
public:
 int x = 7;
};
class C
{
  void foo(){
  int  k = x;
  }
};

And k will be set depending of it class: if k in vec_ca k = 6; if k in vec_cb k = 7. Is it possible to be done?

Aucun commentaire:

Enregistrer un commentaire