1> c:\program files\microsoft visual studio 11.0\vc\include\string.h(110) : 参见“strcpy”的声明 10
#ifndef_STUDENT_H#define_STUDENT_HclassStudent{public:Student(intx=0,char*y="",char*z...
#ifndef _STUDENT_H#define _STUDENT_Hclass Student{public: Student(int x=0,char * y="",char * z=""); void GetAge(); void GetName(); void GetSex(); static void DisplayNum(); ~Student();private: int m_iAge; char m_cName[10]; char m_cSex[10]; static int m_iNum;};#endifint Student::m_iNum=0;报错:1>------ 已启动生成: 项目: c++5_1, 配置: Debug Win32 ------1> demo.cpp1> 正在生成代码...1> 正在编译...1> 实现.cpp1>f:\c++5_1\c++5_1\实现.cpp(7): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.1> c:\program files\microsoft visual studio 11.0\vc\include\string.h(110) : 参见“strcpy”的声明1>f:\c++5_1\c++5_1\实现.cpp(8): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.1> c:\program files\microsoft visual studio 11.0\vc\include\string.h(110) : 参见“strcpy”的声明1> 正在生成代码...1>实现.obj : error LNK2001: 无法解析的外部符号 "private: static int Student::m_iNum" (?m_iNum@Student@@0HA)1>F:\c++5_1\Debug\c++5_1.exe : fatal error LNK1120: 1 个无法解析的外部命令========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
这是实现文件
#include "Student.h"
#include <iostream>
using namespace std;
Student::Student(int x ,char * y ,char* z)
{
m_iAge=x;
strcpy(m_cName,y);
strcpy(m_cSex,z);
m_iNum++;
}
void Student::GetAge()
{
cout<<"请输入年龄:";
cin>> m_iAge;
return;
}
void Student::GetName()
{
cout<<"请输入名字:";
cin>>m_cName;
return;
}
void Student::GetSex()
{
cout<<"请输入性别:";
cin>>m_cSex;
return;
}
void Student::DisplayNum()
{
cout<<m_iNum;
return;
}
Student::~Student()
{
m_iNum--;
} 展开
这是实现文件
#include "Student.h"
#include <iostream>
using namespace std;
Student::Student(int x ,char * y ,char* z)
{
m_iAge=x;
strcpy(m_cName,y);
strcpy(m_cSex,z);
m_iNum++;
}
void Student::GetAge()
{
cout<<"请输入年龄:";
cin>> m_iAge;
return;
}
void Student::GetName()
{
cout<<"请输入名字:";
cin>>m_cName;
return;
}
void Student::GetSex()
{
cout<<"请输入性别:";
cin>>m_cSex;
return;
}
void Student::DisplayNum()
{
cout<<m_iNum;
return;
}
Student::~Student()
{
m_iNum--;
} 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏10(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询