twitu's blog

By twitu, history, 4 weeks ago, In English,

I have a library of data structures I commonly use, however I find it difficult to use them on codeforces because it requires one pubic class only. There are other editors however that support multiple classes.

This my programme structure:
~~~~~
class Digraph {}
class Bag {} // Bag is used by Digraph
public class {
static digraph
// declare other static variables
static recursivefunction () // operates on digraph
static solution () // computes and prints solution and calls recursive function, instantiate digraph
static void main() // calls solution
}
~~~~~
The problem came up because codeforces judge would accept only one public class

So i tried this:
~~~~~
public class { class Digraph {}
class Bag {} // Bag is used by Digraph
static digraph
// declare other static variables
static recursivefunction () // operates on digraph
static solution () // computes and prints solution and calls recursive function, instantiate digraph
static void main() // calls solution
}
~~~~~
This gives an error that when declaring digraph because Main.this.Digraph cannot be accessed from a static context.

So, how do i use classes in a conflict free manner. Your answer would be of great help.

 
 
 
 
  • Vote: I like it  
  • +8
  • Vote: I do not like it  

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by twitu (previous revision, new revision, compare).

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Nested static classes are allowed. I have never tried non-static nested class though.

»
4 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

You should make the inner class as static. You're getting this error because you're trying to create an object of inner class without creating an object of the outer class . Check out my solution