类的hello,world

写类的hello,world程序 如下

#include <iostream>
using namespace std;
#include <string.h>

class A{
    protected:
    string a;
    public:
        A(){
                a ="hello,world";
        }
        string  get_a(){
            return a;
        }
};
class B : public A{

};
int main(){
        B b;
        cout<<b.get_a()<<endl;;
}


posted @ 2017-03-14 19:09  开往春天的拖拉机  阅读(115)  评论(0编辑  收藏  举报