#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; }
运行结果:
知识点总结:
数组和指针做对象
学习心得:
好好学习 天天向上
原文地址:http://blog.csdn.net/ljd939952281/article/details/44901521