新微赢技术网
标题:
高手来看下
[打印本页]
作者:
一世豪杰
时间:
2009-11-3 03:50
标题:
高手来看下
#include"name.h"
#include<string>
using std::string;
#include<iostream>
using std::ostream;
using std::istream;
#include<iomanip>
using std::setw;
using std::left;
#include<cstring>
using std::strlen;
using std::strcpy;
int Name::number = 0;
Name::Name(const char * const f , const char * const l)
{
setFirstName(f);
setLastName(l);
Name::number ++;
}
Name::~Name()
{
delete [] firstname;
delete [] lastname;
number--;
}
void Name::setFirstName( const char * const first)
{
firstname = new char[ strlen( first ) + 1 ];
strcpy( firstname , first );
}
void Name::setLastName( const char * const last)
{
lastname = new char[ strlen( last ) + 1 ];
strcpy( lastname , last );
}
char *Name::getFirstName()
{
return firstname;
}
char *Name::getLastName()
{
return lastname;
}
ostream &operator<<( ostream &output , const Name &m )
{
output <<"Welcome to GradeBood System" <<'\n'<<"Number is: "<<setw(2)<<left<< m.number << '\t'<<"Name is: " << m.firstname <
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2