LintCode (9)Fizz Buzz

LintCode (9)Fizz Buzz

下面是AC代码,C++风格:

 class Solution {
public:
vector<string> fizzBuzz(int N) {
vector<string> Answer;
for(int i = ;i <= N;i++) {
if(i % == ) {
Answer.push_back("fizz buzz");
} else if(i % == ) {
Answer.push_back("fizz");
} else if(i % == ) {
Answer.push_back("buzz");
} else{
Answer.push_back(to_string(i));
}
}
return Answer;
}
};

此处很奇怪,为何将成员函数名fizzBuzz的首字母改成大写,编译返回不通过?

编译警告

Main.cpp: In function ‘int main()’:
Main.cpp:26:39: error: ‘class Solution’ has no member named ‘fizzBuzz’
vector results = solution.fizzBuzz(n);

^

EXITCODE=1

上一篇:大数据江湖之即席查询与分析(下篇)--手把手教你搭建即席查询与分析Demo


下一篇:[重构到模式-Chain of Responsibility Pattern]把Fizz Buzz招式重构到责任链模式