8
指定我已经以这种方式定义的函数,如静态在我的课(相关代码段)静态功能:存储类可能不被这里
#ifndef connectivityClass_H
#define connectivityClass_H
class neighborAtt
{
public:
neighborAtt(); //default constructor
neighborAtt(int, int, int);
~neighborAtt(); //destructor
static std::string intToStr(int number);
private:
int neighborID;
int attribute1;
int attribute2;
#endif
,并在.cpp文件作为
#include "stdafx.h"
#include "connectivityClass.h"
static std::string neighborAtt::intToStr(int number)
{
std::stringstream ss; //create a stringstream
ss << number; //add number to the stream
return ss.str(); //return a string with the contents of the stream
}
我得到一个错误(VS C++ 2010)在.cpp文件中说“存储类可能不在此处指定”,我无法弄清楚我做错了什么。
p.s.我已经阅读this这看起来像一个重复的,但我不知道 - 就像他一样 - 我是对的,编译器是挑剔的。任何帮助表示赞赏,我无法找到关于此的任何信息!
你确定'可变'吗?它在BNF中显示为一个* storage-class-specifier *,但它不像一个行为。 'thread_local'是C++ 11中的存储类说明符。 –
@ BenVoigt:是的,C++ 03§7.7.1明确列出了这5个说明符。 –