为什么我实例化不成功,而且s_iCount没有加一
Tank.h
#ifndef TANK_H
#define TANK_H
#include <iostream>
using namespace std;
class Tank
{
public:
Tank(char code);
~Tank();
void fire();
static int getCount();
private:
char m_cCode;
static int s_iCount;
};
#endifTank.cpp
#include "Tank.h"
int Tank::s_iCount = 0;
Tank::Tank(char code)
{
m_cCode=code;
s_iCount++;
cout << "Tank(code)" << endl;
}
Tank::~Tank()
{
s_iCount--;
cout << "~Tank()" << endl;
}
void Tank::fire()
{
cout << "Tank::fire()" << endl;
}
int Tank::getCount()
{
return s_iCount;
}demo.cpp
#include "Tank.h"
int main()
{
Tank tank1("A");
cout << Tank::getCount() << endl;
}错误提示1:
错误 C2664 “Tank::Tank(const Tank &)”: 无法将参数 1 从“const char [2]”转换为“char”
错误提示2:
错误(活动) 没有与参数列表匹配的构造函数 "Tank::Tank" 实例 2.12静态 d:\others\Visual Studio 2015\C++\2.12静态\2.12静态\源.cpp 5