友元实战访问类模板
1 /* 友元实战访问类模板 */
2
3 #include "dialog.h"
4 #include <QApplication>
5 #include<QPushButton>
6 #include<QLabel>
7
8 template <class T>
9 class mywindow
10 {
11 private:
12 T *p;
13 void show()
14 {
15 p->show();
16 }
17 friend void run( mywindow <Dialog> &d);
18
19 public:
20 mywindow()
21 {
22 p= new T;
23 }
24
25 };
26
27 void run( mywindow <Dialog> &d)
28 {
29 d.show();
30 }
31
32 int main(int argc, char *argv[])
33 {
34 QApplication a(argc, argv);
35
36 mywindow <Dialog> my1;
37
38 run(my1);
39
40 return a.exec();
41 }
长风破浪会有时,直挂云帆济沧海
posted on 2015-06-12 16:20 Dragon-wuxl 阅读(102) 评论(0) 收藏 举报
浙公网安备 33010602011771号