2022年7月16日

使用递归算法使字符串s倒序。

摘要: 使用递归算法使字符串s倒序。string daoxu(string &str){ static string news; static int length=str.length(); length--; if(length<0){ str.swap(news); return str; }else 阅读全文

posted @ 2022-07-16 10:31 zwhyh 阅读(157) 评论(0) 推荐(0)

2022年6月28日

定义X,Y,Z,函数h(X*),满足:类X有私有成员i,Y的成员函数g(X*)是X的友元函数,实现对X的 成员i加1;类Z是类X的友元类,其成员函数f(X*)实现对X的成员i加5;函数h(X*)是X的友元函数,实现对 X的成员i加10.在一个文件中定义和实现类,在另一个文件中实现main()函数。

摘要: 1、定义 class x{…… private: int i; } class Y{……} class Z{……} 后会报错,发现类Y的成员函数g(X*)无法访问类X的成员函数。这是因为类X定义在类Y前,编译器不知道有Y这个类。 即使在第一行声明了“class Y;”,编译器也无法知道类Y中究竟有什 阅读全文

posted @ 2022-06-28 17:23 zwhyh 阅读(428) 评论(1) 推荐(0)

导航