samedi 8 mai 2021

C++: Access class members variable from outside

I have a class defined in header file as below:

// picture.hpp:
class Picture {
  public:
  int count;
  void draw();
};

Corresponding implementing source file:

// picture.cpp
import "picture.hpp";
Picture::draw() {
  // some code
  someFunction();
}

void someFunction() {
 //some code
 // can I use variable "count" declared in Picture class in this function
}

Can someFunction() access members of Class Picture?

Aucun commentaire:

Enregistrer un commentaire