作者在 2011-03-31 11:29:38 发布以下内容
#include<iostream>
using namespace std;
class user{
public:
    user(){
    name=new char[20];
    }
    void getuse();
    void setuse(char *n,int p);
    ~user(){
    delete[]name;
    }
private:
    char *name;
    int password;
};
void user::setuse(char *n,int p){
    name=n;
    password=p;

}
void user::getuse(){
cout<<"帐号:"<<name<<" 密码:"<<password<<endl;
}
int main()
{
    cout<<"The name and the password"<<endl;
user ip;
ip.setuse("my",123);
ip.getuse();
return 0;
}












#include<iostream>
using namespace std;
class user{
public:
    user(){
    name=new char[20];
    }
    void getuse();
    void setuse();
    ~user(){
    delete[]name;
    }
private:
    char *name;
    int password;
};
void user::setuse(){
    cin>>name>>password;
    

}
void user::getuse(){
cout<<"帐号:"<<name<<" 密码:"<<password<<endl;
}
int main()
{
    cout<<"The name and the password"<<endl;
user ip;
ip.setuse();
ip.getuse();
return 0;
}
默认分类 | 阅读 588 次
文章评论,共0条
游客请输入验证码
文章分类
文章归档
最新评论