标签:ted return std lock cte alt cout play blog
1、
1 #include <iostream> 2 using namespace std; 3 4 class Time{ 5 friend void func(Time &t); // 声明全局函数为一个友元函数 6 public: 7 Time(int h, int m, int s) : i_mHour(h), i_mMin(m), i_mSecon(s) { } // 构造函数 8 private: 9 int i_mHour; 10 int i_mMin; 11 int i_mSecon; 12 }; 13 14 static void func(Time &t) // 全局函数 15 { 16 cout << t.i_mHour << ":" << t.i_mMin << ":" << t.i_mSecon << endl; 17 } 18 19 int main(void) 20 { 21 Time t = {10, 20, 30}; 22 func(t); 23 return 0; 24 }
标签:ted return std lock cte alt cout play blog
原文地址:http://www.cnblogs.com/deng-tao/p/6011796.html