#include <
iostream>
using namespace std;
class Test
{
public:
Test( int age = 0, char *name = "/0")
{
Test::age = age;
strcpy(Test::name,name);
}
void outmembers( ostream &out)
{
out<<"Age:"<<age<<endl<<"Name:"<< this->name<<endl;
}
friend ostream& operator <<( ostream& ,Test&);
protected:
int age;
char name[50];
};
ostream& operator <<( ostream& out,Test &temp)
{
temp.outmembers(out);
return out;
}
int main()
{
Test a(24,"管宁");
cout<<a;
system("pause");
}
using namespace std;
class Test
{
public:
Test( int age = 0, char *name = "/0")
{
Test::age = age;
strcpy(Test::name,name);
}
void outmembers( ostream &out)
{
out<<"Age:"<<age<<endl<<"Name:"<< this->name<<endl;
}
friend ostream& operator <<( ostream& ,Test&);
protected:
int age;
char name[50];
};
ostream& operator <<( ostream& out,Test &temp)
{
temp.outmembers(out);
return out;
}
int main()
{
Test a(24,"管宁");
cout<<a;
system("pause");
}