如下代码,result变量的输出结果是多少?
#include<iostream> using namespace std; int i=1; class MyCls{ public: MyCls():m_nFor(m_nThd),m_nSec(i++),m_nFir(i++),m_nThd(i++){ m_nThd=i; } void echo(){ cout<<"result:"<<m_nFir+m_nSec+m_nThd+m_nFor<<endl; } private: int m_nFir; int m_nSec; int m_nThd; int &m_nFor; }; int main() { MyCls oCls; oCls.echo(); return 0; }
输出结果m_nFir+m_nSec+m_nThd+m_nFor=1+2+4+4=11