ITeye博客

C++ 类

hwpok · 2009-07-02 21:04 · C/C++ · Markdown

Persion.h

#include <string>
using namespace std;

#ifndef PERSION_H
#define PERSION_H
class Persion
{
private:
    string name;
public:
    Persion(string name);
    void say();
};
#endif

Persion.cpp

#include <iostream>
#include <string>
#include "Persion.h"
using namespace std;
Persion::Persion(string name)
{
    this->name=name;
}
void Persion::say()
{
    cout<<"my name is "<<this->name<<endl;
}
void main()
{
    Persion persion("huyvanpull");
    Persion *pPersion = &persion;
    pPersion->say();
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。