Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
class MyClass {
private:
QString* data1;
QString* data2;
// Return a number depending on the value of param
QString* privateData(const int param);
public:
// Return a string reflecting the internal data
const QString readData(const int param) const;
// Append to the internal data
void appendData(const int param, QString* value);
// Add ctors/dtors, etc
};
QString* MyClass::privateData(const int param) {
if (param == 1)
return data1;
else
return data2;
}
const QString* MyClass::readData(const int param) const {
const QString* data = privateData(param);
return data;
}
void MyClass::appendData(const int param, QString* value) {
QString* data = privateData(param);
data->append(&value);
}
|



