[问题] static用法

楼主: oToToT (屁孩)   2018-11-22 00:11:53
开发平台(Platform): (Ex: Win10, Linux, ...)
Linux, OS X
编译器(Ex: GCC, clang, VC++...)+目标环境(跟开发平台不同的话需列出)
g++-8 (Homebrew GCC 8.2.0) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
g++ (GCC) 8.1.1 20180531
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)

问题(Question):
刚刚发现这份程式码用我手边的编译器都编不过,但是丢到一些较旧的编译器却编的过
而自己要让他编的过则要把static拿掉(改成 const int INF = 1000000000)才会过
之前一直以为static只是会让class共用一个实体,不会每一个都重新生成而已,但好像
又不太对,不知道static该如何准确理解呢?
喂入的资料(Input):

预期的正确结果(Expected Output):
编译成功
错误结果(Wrong Output):
Undefined symbols for architecture x86_64:
"KuhnMunkres::INF", referenced from:
KuhnMunkres::solve() in ccXZSn3o.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
程式码(Code):(请善用置底文网页, 记得排版,禁止使用图档)
https://gist.github.com/oToToT/e16c9e8a68661fa980a0c827c907d8e8
补充说明(Supplement):
上面列的三个编译器都不能顺利编译,但我用了Codeforces的跟Ideone提供的编译器都可
以顺利编译
作者: kokal (细菌)   2018-11-22 00:33:00
c++ structure的static variable 要另外宣告-INF?

Links booklink

Contact Us: admin [ a t ] ucptt.com