, 나는오류 : 예상되는 주요 표현 '('다음 코드에서 토큰
을 얻고 전에In member function ‘void no_matches::test_method()’:
error: expected primary-expression before ‘(’ token
auto subject = anagram("diaper");
코드는 여기 여기
#include "anagram.h"
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
using namespace std;
BOOST_AUTO_TEST_CASE(no_matches)
{
auto subject = anagram("diaper");
auto matches = subject.matches({"hello", "world", "zombies", "pants"});
vector<string> expected;
BOOST_REQUIRE_EQUAL_COLLECTIONS(expected.begin(), expected.end(), matches.begin(), matches.end());
};
시작 anagram.cpp
#include "anagram.h"
#include <boost/algorithm/string/case_conv.hpp>
#include <algorithm>
#include <cctype>
using namespace std;
namespace
{
string make_key(std::string const& s)
{
string key{boost::to_lower_copy(s)};
sort(key.begin(), key.end());
return key;
}
}
namespace anagram
{
anagram::anagram(string const& subject)
: subject_(subject),
key_(make_key(subject))
{
}
vector<string> anagram::matches(vector<string> const& matches)
{
vector<string> result;
for (string const& s : matches) {
if (s.length() == key_.length()
&& boost::to_lower_copy(s) != boost::to_lower_copy(subject_)
&& make_key(s) == key_) {
result.push_back(s);
}
}
return result;
}
}
입니다
다음은 anagram.h입니다.
#if !defined(ANAGRAM_H)
#define ANAGRAM_H
#include <string>
#include <vector>
namespace anagram
{
class anagram
{
public:
anagram(std::string const& subject);
std::vector<std::string> matches(std::vector<std::string> const& matches);
private:
std::string const subject_;
std::string const key_;
};
}
#endif
로컬 컴퓨터에서이 오류를 가져 오지 못했습니다. 나는 https://travis-ci.org으로 건축 할 때만 나는 그것을 얻고있다. 누군가가 버그를 찾도록 도와 줄 수 있습니까?
'anagram' 정의에 대한 코드를 게시 할 수 있습니까? – CoryKramer
클래스 정의 끝에 세미콜론을 잊어 버렸습니다. –
아나그램 정의의 코드는 여기에 있습니다. –