c++类(自学笔记)

仅供自学

#include<iostream>
#include<string>

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;
}

猜你喜欢

转载自blog.csdn.net/qq_45347584/article/details/103959523