//#include "stdafx.h"//If the vc++6.0, with this line.
#include
#include
using namespace std;
class Client{
char *m_name;
int m_age;
public:
Client(char *name,int age){
m_name=new char[strlen(name)+1];
strcpy(m_name,name);
m_age=age;
}
~Client(){
delete []m_name;
}
void display(void){
cout << "1. Name:" << m_name << endl;
cout << "2. Age:" << m_age << endl;
}
};
int main(int argc,char *argv[]){
char name[20];
int age;
cout << "Please enter the user information...\n";
cin >> name >> age;
Client t(name,age);
t.display();
return 0;
}
#include
using namespace std;
class Client{
private:
char* m_name;
int m_age;
public:
Client(char* name,int age) {
m_name=name;
m_age=age;
}
~Client(){
delete m_name;
}
void display()
{
cout<<"Name:"<
}
};
int main()
{
char inputName[100];
int inputage;
bool flag=true;
while(flag)
{
cout<<"请输入name:";
cin>>inputName;
cout<<"请输入age:";
cin>>inputage;
Client client(inputName,inputage);
client.display();
cout<<"是否继续?1是,0否:";
cin>>flag;
}
}
大概就是这样。
什么网站Orz