2017-09-29 13 views
-1

我通过下文详述的误差得到相当困惑:C++ - 后函数声明预期的函数体 - 的Xcode 9.0

#include "width.hpp" 
#include <vector> 
#include <string> 

using std::string;  using std::vector; 
using std::max; 
//Expected function body after function declarator error message here 
string::size_type width(const vector<string>& v) 
{ 
    string::size_type maxlen = 0; 
    for (vector<string>::size_type i = 0; i != v.size(); ++i) 
    { 
     maxlen = max(maxlen, v[i].size()); 
    } 
    return maxlen; 
} 

与头文件是如下:

#ifndef GUARD_width_hpp 
#define GUARD_width_hpp 

#include <vector> 
#include <string> 

std::string::size_type width(const std::vector<std::string>&) 

#endif /* width_hpp */ 

可能有人为我提供一些帮助?

干杯!

+0

请编辑您的问题,将*所有*相关代码(和*仅*相关代码)作为*文本*包含在其中。在你的情况下,这也意味着'width.hpp'的内容。 – Angew

回答

0

问题解决:我在头文件中的函数声明符之后添加了一个分号。感谢帮派!