vc第二讲 this指针
第二讲一构造函数例 1.3 .1// l_3_2.cpp : Defines the entry point for the console application.#include Hstdafx.
第二讲 一构造函数 1.3.1 例 //l_3_2.cpp:Definestheentrypointfortheconsoleapplication. H #includestdafx.h" #includc<iostrcam.h> #include<string> classCPcrson ( public: CPerson(char*stnfloath,floatw)//A :构造函数 ( strcpy(natne,str);height=h;weight=w; ) CPerson(char*str)//B :构造函数 ( strcpy(name,str); I CPcrson(floath,floatw=120);//C :构造函数 public: voidprint() ( coutvv""vvnamevvNvheightvv 姓名:、身高:飞体重: "«weight«endl; I private: cha namcl20]; //姓名 r floa height; //身高 floa t //体重 t weight; ); CPerson::CPerson(floath.floatw) ( height=h;weight=w; ) intmain(intargc,char*argv[]) | CPersonone("DING"); one.print(); CPersontwo(l70,130);

