hi everybody,
i would be glad if someone could show me how the Get and Set functions work.
thanks.

Get and set functions are just a public interface for getting read/write access to private data members:

#include <iostream>

class EdRules {
  bool _isEdAwesome;
public:
  EdRules(): _isEdAwesome(true) {}

  // Get function, gives read access to _isEdAwesome
  bool IsEdAwesome() const { return _isEdAwesome; }

  // Set function, gives write access to _isEdAwesome
  void IsEdAwesome(bool value) { _isEdAwesome = value; }
};

int main()
{
  EdRules ed;

  // Ed is awesome!
  std::cout << std::boolalpha << ed.IsEdAwesome() << '\n';

  ed.IsEdAwesome(false);

  // Hmm, maybe not...
  std::cout << std::boolalpha << ed.IsEdAwesome() << '\n';
}

thank you Edward. could you throw more light on the subject?

What can I help you understand better?

i think using get function, you can use private members which you declared, you can use anywhere in your program.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.