8-1.cpp
来自「为初学者提供的最佳的C++程序设计源程序库」· C++ 代码 · 共 34 行
CPP
34 行
#include<iostream.h>
#include<string.h>
class phone
{
char name[50];
char tell[15];
public:
void store(char *n,char *num);
void print();
};
void phone::store(char *n,char *num)
{
strcpy(name,n);
strcpy(tell,num);
}
void phone::print()
{
cout<<name<<":"<<tell;
cout<<"\n";
}
main()
{
phone *p;
p=new phone;
if(!p)
{
cout<<"Alloction error.";
return 1;
}
p->store("Wang Qi Sheng","010 66745678");
p->print();
delete p;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?