语法:构造函数():属性1(值1),属性2(值2),…{}
#include<iostream> using namespace std; class WLM { public: WLM(int a,int b,int c):m_a(a),m_b(b),m_c(c) { } int m_a; int m_b; int m_c; }; void test() { WLM zjy(10,20,30); cout << "m_a =" << zjy.m_a << endl; cout << "m_b =" << zjy.m_b << endl; cout << "m_c =" << zjy.m_c << endl; } int _tmain(int argc, _TCHAR* argv[]) { test(); system("pause"); return 0; }
原创文章,作者:,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/277319.html