64,682
社区成员
发帖
与我相关
我的任务
分享
#ifndef PERSON_H
#define PERSON_H
//Defination of Person class and related functions gose here
#include <iostream>
#include <string>
class Person{
public:
Person():sName("zcy"),sAddress("HIT"){}
Person(std:string name,std::string add)
{sname = name;sAddress = add;}
std::string get_Name()const
{return sName;}
std::string get_Address()const
{return sAddress;}
private:
std::string sName;
std::string sAddress;
};
#endif
#include <iostream>
#include "Person.h"
int main()
{
Person p;
std::cout<<p.get_Name()<<"@"<<p.get_Address()<<std::endl;
return 0;
}
Person(std:string name,std::string add)
{sname = name;sAddress = add;}
change to:
Person(std::string name,std::string add):sname(name), sAddress(add)
{}
#ifndef PERSON_H
#define PERSON_H
//Defination of Person class and related functions gose here
#include <iostream>
#include <string>
class Person{
public:
Person():sName("zcy"),sAddress("HIT"){}
Person(std::string name,std::string add)
{sName = name;sAddress = add;} //LZ很不小心啊o(∩_∩)o...
std::string get_Name()const
{return sName;}
std::string get_Address()const
{return sAddress;}
private:
std::string sName;
std::string sAddress;
};
#endif
#ifndef PERSON_H
#define PERSON_H
//Defination of Person class and related functions gose here
#include <iostream>
#include <string>
using namespace std;
class Person
{
public:
Person():sName("zcy"),sAddress("HIT"){}
Person(string name,string add)
{
sName = name;
sAddress = add;
}
string get_Name()const
{
return sName;
}
string get_Address()const
{
return sAddress;
}
private:
string sName;
string sAddress;
};
#endif
#include "Person.h"
int main()
{
Person p;
cout<<p.get_Name()<<"@"<<p.get_Address()<<endl;
return 0;
}