c++ - 请问一下为什么leetcode上那个只有一个class类?
ringa_lee
ringa_lee 2017-04-17 13:56:36
0
2
1096

用c++刷题,发现只有一个class类。是leetcode自己有main函数哪些吗?然后是直接调用这个类,去测试运行的吗?如果我要用一个全局变量怎么办哦?第一次上leetcode,不太明白,,,

ringa_lee
ringa_lee

ringa_lee

reply all(2)
巴扎黑

It is best not to define global or static variables outside the class. This will affect your test results, because the test cases all use this piece of code. (Probably it just included this class file).

The correct approach is to add member variables to the class and initialize them in the default constructor.

For other related questions, please see the official FAQ.

https://leetcode.com/faq/

Peter_Zhu

leetcode requires you to write a function to complete the specified requirements, and the others have already been written. Not all codes have to be written by yourself

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!