Any access outside of the class is "prohibited". Unless you for example use the friend class. (Which let's any other class access to the private members of the class)
You can define friend-class like this:
class MyClass {
friend class MyClassB;
public:
MyClass();
~MyClass();
private:
int number;
};
Then MyClassB will have access to the private variables of "MyClass".
If you do something like this:
class MyClass {
public:
MyClass();
~MyClass();
private:
int number;
};
int main(int argc, char *argv[])
{
MyClass A;
A.number = 11; // You can't do this
if(A.number > 10) { // Either you can't do this.
qDebug() << "It's more than 10"; // Qt. well.
}
return 0;
}
You'll get an "error" because you're trying to access A.number from outside of the class.
But if you want to access from some function inside the class:
class MyClass {
public:
myClass() {
number = 10;
if(number > 10) {
qDebug() << "It's more than 10"; // Qt. well.
}
}
~MyClass();
private:
int number;
};