What is a local class? Why can it be useful?


Local class is a class defined within the scope of a function — any function, whether a member function or a free function. For example:

// Example 2: Local class
//
int f()
{
class LocalClass
{
// …
};
// …
};

Like nested classes, local classes can be a useful tool for managing code dependencies.



Explore posts in the same categories: C/C++ Interview Questions


BOOKMARK THIS : del.icio.us | Digg it | Furl | reddit |


Related Questions :

  • What are different types of inner classes?
  • Nested top-level classes, Member classes, Local classes, Anonymous classes Nested top-level classes- If you declare a class within a class and...
  • What are different types of inner classes?
  • Nested top-level classes, Member classes, Local classes, Anonymous classes Nested top-level classes- If you declare a class within a class and...
  • What modifiers can be used with a local inner class?
  • A local inner class may be final or abstract....
  • What is Local client view?
  • The local client view specification is only available in EJB 2.0. Unlike the remote client view, the local client view...
  • What modifiers may be used with an inner class that is a member of an outer class?
  • A (non-local) inner class may be declared as public, protected, private, static, final, or abstract....
  • What are the special design care that must be taken when you work with local interfaces ?
  • EIt is important to understand that the calling semantics of local interfaces are different from those of remote interfaces. For...
  • What is the difference between a field variable and a local variable?
  • A field variable is a variable that is declared as a member of a class. A local variable is a...
  • What is the default value of the local variables?
  • The local variables are not initialized to any default value, neither primitives nor object references. If you try to use...
  • What is the purpose of the File class?
  • The File class is used to create objects that provide access to the files and directories of a local file...
  • What is the relationship between local interfaces and container-managed relationships?
  • Entity beans that have container-managed relationships with other entity beans, must be accessed in the same local scope as those...

    Comment:

    You must be logged in to post a comment.