Questions tagged [nested-class]

In Object Oriented programming, a class defined inside another class. Also called "inner class".

In there are times when a class A is used only as a component of another class B and should not be instanced outside B. In those cases proper encapsulation suggest defining that class as a nested or inner class.

Several languages support this feature (C++, Java, .Net languages, D, python, for example) although with minor differences in where nested classes can be defined, how can they be used; and some languages support more than one variety of nested class.

574 questions
0
votes
1 answer

Accessing shared parent fields/properties in nested classes

suppose we have: Class Outer Public Shared Index As Integer Class Inner Private Index As Integer Public Shared Sub Test() ' how do I refer to the parent's Index? End Sub End Class End Class then I can't use…
ekkis
  • 9,804
  • 13
  • 55
  • 105
0
votes
1 answer

Python Tkinter: Cant configure button from another class

I am just learning MVC and im using Tkinter to do so, but while i am trying to configure a button from a class within a class i keep getting this error Traceback (most recent call last): File "Controller.py", line 22, in controller =…
0
votes
1 answer

C++ inheritance and instantiation of depended classes

I'm trying to extend an existing application using an agile library. The library forces me to create a concrete interface class, InterfaceToA to interface to my application. However, within my application, the most natural place (without a major…
johntfoster
  • 361
  • 5
  • 17
0
votes
1 answer

AsyncTask, inner classes and Buttons states

For a musical application (a sequencer), I have a few buttons static ArrayList
0
votes
1 answer

Nested classes and implementing interfaces in java

Although this code is from an algorithm text, I have a bit of a trouble regarding nested classes and interfaces - actually, 90% of my confusion arises from how this code implements the interface. Again, this question is not about the algorithm…
user1164937
  • 1,979
  • 2
  • 21
  • 29
0
votes
3 answers

Can't figure out correct argument form - calling a method from within a static nested class in Java

I'm testing code copied from a Java Android examples site. I'm trying to modify it to start a new activity when a user clicks into a row of the current activity. So I'm using the Intent method but I'm not able to figure out how to reference the…
0
votes
2 answers

Python: How to get Outer class variables from inner static class?

I want to specify variable once by making instance Outer(variable), than this variable use in all static classes, how should I do that? Is there any other solution than use not static methods and pass Outer into each inner class? class Outer(): …
Meloun
  • 13,601
  • 17
  • 64
  • 93
0
votes
1 answer

PHP how to declare/use a nested class

I need an associative array of the basic structure $digest = { 'subscriptions' => [ { 'time' => 0825, 'company' => "Facebook", }, { 'time' => 0930, 'company' => "Twitter", } ], …
djechlin
  • 59,258
  • 35
  • 162
  • 290
0
votes
1 answer

Android spinner not displayed when I return to the main view from another

I'm new to Android and am experimenting with navigating and displaying information. I successfully put a spinner on the main view of this app, but when I click to another view (via a butoton that executes goFilter) and return (via a button that…
Mike
  • 1
0
votes
1 answer

Ruby on Rails - how to make nested objects

I want to build a structure of nested objects without creating models for each of them. This structure should be used for intermediate calculations, for display purposes only and not persist in database. What is the right Rails-way to make object…
Paul
  • 25,812
  • 38
  • 124
  • 247
0
votes
1 answer

Do nested structs affect performance?

If the nested struct will contain only static constant members, will it affect performance anyhow? I want to use it to scope these constants. class File { public: struct Mode { static const int Read = 0x01, Write = 0x02,…
HemoGoblin
  • 155
  • 4
0
votes
3 answers

java - Variable for variable names ? or is there anything similar to MACRO?

Is it possible to create variable for variable Names ? like this class example { String VAR1 = "id"; String VAR2 = "mark"; public foo() { int VAR1; int VAR2; } } Or Say I'm having nested class Parent and Child. class…
shiva
  • 463
  • 2
  • 7
  • 9
0
votes
1 answer

nested class definition without creating additional global objects

I'm trying to create nested class definitions in javascript to have only one global object. At the moment we define new classes like this: FOO.Navigation.Sidebar.Tooltip = function() { }; So in each function definition we have to repeat the whole…
Stefan Ramson
  • 531
  • 1
  • 6
  • 18
-1
votes
3 answers

How to inherit generic class

Work on C# .I want to inherit generic class for this purpose i write the bellow syntax public class Father { public string FatherName { get; set; } } public class Mother { public string MotherName { get; set; } …
shamim
  • 6,640
  • 20
  • 85
  • 151
-1
votes
2 answers

No enclosing instance is in scope with double brace initializers

I have some classes nested one in another public abstract class I { public abstract int f(); } public class J { private List li; public J(List l) { li = l; } } public class A // first class { private int x; //…
haael
  • 972
  • 2
  • 10
  • 22