C++ primer plus(第6版)中文版编程练习答案第12章.docxVIP

  • 94
  • 0
  • 约1.31万字
  • 约 21页
  • 2017-08-03 发布于河南
  • 举报

C++ primer plus(第6版)中文版编程练习答案第12章.docx

1、//cow.h#ifndef COW_H_#define COW_H_#includeiostream#includestring#includestdio.husing namespace std;class Cow{private:char name[20];char *hobby;double weight;public:Cow();Cow(const char *nm, const char *ho, double wt);Cow(const Cow c);~Cow();Cow operator=(const Cow c);voidShowCow()const;};#endif//cow.cpp#includecow.hCow::Cow(){name[0] = \0;hobby = new char[1];hobby[0] = \0;weight = 0;}Cow::Cow(const char *nm, const char *ho, double wt){strcpy_s(name, 20, nm);hobby = new char[strlen(ho)+1];strcpy_s(hobby, strlen(ho) + 1, ho);weight = wt;}Cow::Cow(const Cow c){strcpy_s(name, 20, );hobby = new

文档评论(0)

1亿VIP精品文档

相关文档