我想在我的类CountInv中写一个静态成员函数,它应该只有这个静态函数而没有其他成员
//反转.h
#ifndef INV_H
#define INV_H
#include <string>
#include <vector>
class CountInv
{
static void count();
}
#endif
//反转.cpp
#include "Inversions.h"
void CountInv::count() { return; };
我收到以下编译器错误:
Error 3 error C2556: 'CountInv CountInv::count(void)' :
overloaded function differs only by return type
from 'void CountInv::count(void)' d:\...\inversions.cpp 4
怎么了?我没有在任何地方声明或定义“CountInv CountInv::count(void)”!!我应该编写类 c-tors、..、d-tors 还是一些静态数据成员以从此函数返回?但这不应该是问题..
最佳答案
不要忘记在类定义之后结束分号 ;
。我认为这是导致模糊编译错误的原因。
关于C++静态成员函数错误C2556重载函数仅返回类型不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18888726/