Блог пользователя twitu

Автор twitu, история, 7 лет назад, По-английски

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.

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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