第五周 课后实践:程序阅读(1)
2015-04-08 08:34
162 查看
问题及代码:
运行结果:
#include <iostream> using namespace std; class base { private: int m; public: base() {}; base(int m){this->m=m;} int get(){return m;} void set(int m){this->m=m;} };//base_end int main() { base *ptr; ptr=new base[2]; ptr->set(30); ptr=ptr+1; ptr->set(50); base a[2]= {1,9}; cout<<a[0].get()<<","<<a[1].get()<<endl; cout<<ptr->get()<<","; ptr=ptr-1; cout<<ptr->get()<<endl; delete[] ptr; return 0; }
运行结果:
相关文章推荐
- 第五周 课后实践--阅读程序(3,4,5,6)
- 第五周 课后实践:阅读程序(1)(2)(3)
- 第五周 课后实践--阅读程序(2)
- 第五周课后实践:阅读程序
- 第五周 课后实践:阅读程序(4)(5)(6)
- 第二周课后实践--阅读程序
- 第一周课后实践:阅读程序1
- 第三周课后实践-阅读程序
- 第2周项目-课后实践·阅读程序(1)
- 第二周--课后实践:阅读程序(1)
- 第二周课后实践-阅读程序
- 第二周 课后实践 阅读程序2
- 第二周--课后实践:阅读程序
- 第二周项目1-课后实践:阅读程序
- 第二周课后实践:阅读程序(1)
- 第一周课后实践:阅读程序2,3
- 第3周课后实践·程序阅读(4)-利用引用访问私有数据成员
- 第3周课后实践·阅读程序(3)-利用函数访问私有数据成员
- 第三周 课后实践 阅读程序
- 第2周项目-课后实践·阅读程序(2)