0

What is a scope of the class object in C++ with example ?

6th Jul 2020, 9:39 AM
Muhammad Roheel Afridi
1 Answer
+ 1
Scope of object is no different than scope of variables. If it goes out of a block, it is destroyed. For eg. Suppose there is a class A. //Class A definition int main() { A a1,a2; //object a1,a2 created { A a3; // object a3 created } //End of block and object a3 destroyed } //End of block and objects a1,a2 destroyed. You can use destructor method to check destruction of objects.
7th Jul 2020, 6:42 AM
Alaska
Alaska - avatar