A class can be declared inside a function or a block. In such cases, it is not visible from anywhere else, and instances thereof can only be created within the scope in which it is declared. This can be useful if you need to hide an ancillary object, which should not be accessible or used anywhere else:void f(const char *text)
{ class Display { //local helper class; visible only inside f() const char *ps; public: Display(const char *t) : ps(t) {} ~Display() { cout<