c++类(自学笔记)

仅供自学

#include
#include

using namespace std;
class preson{
	public:
		preson(const std::string &nm,const std::string &adr){
			name = nm;
			adress = adr;
		};
		std::string getname()const{
	   return name;
    }
		std::string getadress()const{
		return adress;
	}

	private:std::string name;
	private:std::string adress;
};
int main(){
	preson a("chuan","1556");
	//a.name();
	a.getname();
	a.getadress();
	cout << a.getname() << "," << a.getadress() << endl;
	cout << "hello 类" << endl;
	std::system("pause");
	return 0;
}

你可能感兴趣的:(c++)