求大佬帮我看一下这道c++编程题哪里出错了
代码:#include<iostream>#include<cstring>usingnamespacestd;classEmployee{public:Employee...
代码:#include <iostream>#include <cstring>using namespace std;class Employee { public: Employee(long, char*, char*, double ); ~Employee(); void set_id(long); void set_salary(double); void set_name(char * ); void set_address(char* ); long get_id(); double get_salary(); char* get_name(); char* get_addressSecond(); void print(); private: long id; char *name; char *address; double salary; };Employee::Employee(long id0,char* name0,char *address0,double salary0 ){ id=id0; name=new char[strlen(name0)+1]; strcpy(name,name0); address=new char[strlen(address0)+1]; strcpy(address,address0); salary=salary0;}Employee::~Employee(){ delete[] name; delete[] address;}void Employee::set_id(long id0){ id=id0;} void Employee::set_salary(double salary0){ salary=salary0; } void Employee::set_name(char *name0 ){ name=new char[strlen(name0)+1]; strcpy(name,name0);} void Employee::set_address(char* address0){ address=new char[strlen(address0)+1]; strcpy(address,address0);} long Employee::get_id(){ return id;} double Employee::get_salary(){ return salary;} char* Employee::get_name(){ return name;} char* Employee::get_addressSecond(){ return address;}void Employee::print(){ cout<<id<<" "<<name<<" "<<address<<" "<<salary<<endl;}int main(){ Employee e(1,"liziye","qianan",100000.00); e.print(); return 0;}
展开
展开全部
图一不是错误,只是警告,是可以运行的,如果看他不爽可以把char*前加const
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2019-04-05
展开全部
在函数'int main()'中
78 42 [警告]不赞成将字符串常量转换为'char*' [- wwrite -string]
78 42 [警告]不赞成将字符串常量转换为'char*' [- wwrite -string]
78 42 [警告]不赞成将字符串常量转换为'char*' [- wwrite -string]
78 42 [警告]不赞成将字符串常量转换为'char*' [- wwrite -string]
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |