Hello
Im unsure about next situations:
When I want to access m_someint from the test class I would just do m_someint and if I want to access it from another class I would do some_test_object.someint();Code:class test {
public:
int someint() { return m_someint; }
private:
int m_someint;
};
Is this a 'good' way? What do you guys do in this situation?
Another question:
Suppose I have some class and I want to modify/change some data in it:
I have seen a lot of code that uses special method/function to change data this way:Code:class someclass {
private:
int m_somedata;
public:
void set_somedata(int i) { m_somedata = i }
};
set_somedata(20);
But I prefer accessing m_somedata directly (so I'd set class that wants to access data as a friend), because I dont like writing new function for each data object..
What do you think about that?