标签:code pac out class using int() void stream ati
#include <iostream> using namespace std; class A { public: A(int i); void print(); private: const int a; static const int b; }; //静态常数据成员在类外说明和初始化 const int A::b = 10; //常数据成员只能通过初始化列表来获得初值 A::A(int i) : a(i) { } void A::print() { cout << a << ":" << b << endl; } int main() { A a1(10), a2(20); a1.print(); a2.print(); return 0; }
标签:code pac out class using int() void stream ati
原文地址:https://www.cnblogs.com/lyt888/p/12493356.html