private中是一個陣列,可以像圖中所示那樣進行建構式的初始化嗎


uj5u.com熱心網友回復:
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
class A{
private:
int a[2] = {2,3};
public:
A(){std::cout <<a[0]<<" "<<a[1]<<std::endl;}
};
int main(int argc, char** argv){
A a;
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/251840.html
標籤:C++ 語言
