Questions tagged [local-class]

Local classes are classes that are defined in a block, which is a group of zero or more statements between balanced braces. You typically find local classes defined in the body of a method.

64 questions
-1
votes
1 answer

Mutual C++ classes declared inside of a function

How do I define classes inside of a function so that they "know" about each other? Here is a greatly dumbed down version of what I'm trying to understand. I'd like to do something like: void foo () { struct A { static void bar () { …
xscott
  • 2,350
  • 16
  • 18
-1
votes
1 answer

Access control modifiers in local classes - why don't they work?

I have a local class declared in a method, whose fields are declared as being private. However, I am still able to access them directly from the body of the enclosing method - why is this? As a side note, I have declared all of the fields in an…
Lord Cat
  • 401
  • 4
  • 13
-1
votes
1 answer

Can we say that a method-local class is a type of Inner class?

Since we can not use the static modifier with a local class defined inside a method, and since Nonstatic nested classes are Inner classes, we could probably say that a method local class is a type of an Inner class. But on the other hand, we say…
Solace
  • 8,612
  • 22
  • 95
  • 183
-3
votes
2 answers

What calls the greet() method in HelloWorldAnonymousClasses?

In the HelloWorldAnonymousClasses example program (from here): /* * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted…
danger mouse
  • 1,457
  • 1
  • 18
  • 31
1 2 3 4
5