nifty: nifty()

发布时间:2024年01月22日

nifty():
nifty (char * s);
ostream & operator << (ostream & os, nifty & n);

nifty: nifty()

personality = NULL;
talents = 0:

-

nifty: nifty (char * s)

personality = new char [strlen (s) ]:
personality * S:
talents = 0:

-

// points to string containing golfer's name
// holds number of golf games played
// points to first element of array of golf scores

// #1
// #2
// #3
// #4
/7 #5
// ¥6
// #7

ostream & nifty: operator << (ostream & os. nifty & n)

os << n:

5. 对于下面的类声明:
class Golfer

private:
char * fullname:
int games:
int * scores:
public:
Golfer ():
Golfer (const char * name, int g= 0);
// creates empty dynamic array of q elements if g > 0
Golfer (const Golfer & g);
-Golfer():

a. ド列各条语句将调用哪些类方法?
Golfer nancy:
Golfer lulu ("Little Lulu") :
Golfer roy ("Roy Hobbs", 12) :
Golfer * par = new Golfer:
Golfer next = lulu;
Golfer hazzard = "Weed Thwacker":
*par = nancy:
nancy = "Nancy Putter":
b. 很明显,类需要有另外几种方法才能更有用,但是类需要那些方法才能防止数据被损坏呢?

12.5

编程练习

1. 对于下面的类声明:
class Cow {
char name [20]:
char * hobby:
double weight:
public:
Cow{):
Cow (const char * nm. const char * ho. double wt);

文章来源:https://blog.csdn.net/Popcorn_zyh/article/details/129986228
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。