If you need to use a text field in a class in private, and write a public method to get the value of this field, how best to do it? Now I try to use char* pole or char pole[10]; for storage char pole[10]; If I understand correctly, it is impossible to return the char array, and then how to be?
#include <stdio.h> class MyClass { public: int getPole1() { return pole1; } void setPole1(int n) { pole1 = n; } //здесь должны быть аналогичные методы для поля pole2 private: int pole1; char pole2[10]; }; int main() { MyClass my; //здесь я должен установить значение pole2 и затем его получить return 0; }
c++. There are member data and member functions. - αλεχολυτ