how can you access class variables outside the class
Answers
Answer:
python
Explanation:
python/ using variable outside and inside the class and method. in python, we can define the variable outside and inside the class and even inside the methods. let's see how to use and access these variable throughout the program.
»VARIABLE DEFINE OUTSIDE THE CLASS:
the variable that are defined outside the class can be accessed by any class or by any method in the class by just writing the variable name.
Answer:
If you want to access class variables outside the class,go for the access specifier 'public'.
Only public members can be accessed outside the class.
Also,protected members can be accessed in the same class and subclasses.
Eg.in c++
class hello
{
public:
int a; //available throughout the program
}
Explanation: