我在VS2013的一个C++程序触发了一个断点是什么意思啊
#ifndef COW_H_#define COW_H_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); void ShowCow() const;};#endif#include "Cow.h"#include using std::cout;using std::endl;Cow::Cow(){ strcpy_s(name, 20, "Default"); hobby = new char[20]; strcpy_s(hobby, 20, "Default Hobby"); 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, c.name); hobby = new char(strlen(c.hobby)+1); strcpy_s(hobby, strlen(c.hobby) + 1, c.hobby); weight = c.weight;}Cow::~Cow(){ delete[]hobby;}Cow & Cow::operator=(const Cow & c){ if (this == &c) return *this; delete[]hobby; strcpy_s(name,20, c.name); hobby = new char(strlen(c.hobby)+1); strcpy_s(hobby,strlen(c.hobby)+1, c.hobby); weight = c.weight; return *this;}void Cow::ShowCow() const{ cout |
免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。
版权声明:作者保留权利,不代表天盟立场。
|
|
|
|