public:
/ h- Z) D# z2 |: T" B" W8 z* u9 ], y staticlistms_List;
' W V. l" W; y: z staticiter_tms_ListIter;
* e9 S5 {( I$ j5 n& D. M: ]4 E };
5 I8 j7 P7 @5 M0 t6 d //Declarationsofstaticvariables 7 w* {' I. K% \3 J
template ( p' D9 g9 t& S0 n' Q9 c$ w5 A! W
listTAutolists::ms_List; 9 d7 r: |- d" x
template
0 I8 T* N. {% ~. ~$ z$ X, G //typedeftypenamelist::iteratoriter_t; 4 X; Q6 g( c: o4 Z" o- j
typenamelist::iteratorTAutolists::ms_ListIter; & W3 r/ Q# ]- i3 l+ u0 ]
#endif : X; N, [. v. _5 }7 C' Q7 ^ y
测试程序: ! O' H) F* w4 ]& ?- E
点击(此处)折叠或打开 ( e. A) C$ ~1 E9 |
#include
' l9 K2 f8 ]2 D7 P; h7 m0 C #include"TAutolists.h" 0 A) h6 y' U6 h
classvec:publicTAutolists 2 n( E- H7 h% a* T: G1 R6 D% a
{ 6 B! U _7 E* |
public: & ~! V5 v* |2 ^
intm_x; . k# c+ e- V1 s( w! A; O3 B- V
intm_y;
8 h+ ^0 p7 t- {: a1 h };
& Y; a7 K* x) y+ n4 |( i3 ? usingnamespacestd; ' U* _4 Q/ L4 P0 c+ E, ~+ z. B: G" v
/* ; M) g9 \" j n, r/ T q, `5 Q, k
template d! N( l! X' r# p7 T( ^3 v
classA : W S8 p% `( b' _
{
% {/ F6 r6 |. Z/ o public: # Y1 [: o. W3 |, n$ K0 k! _" _
staticTa;
3 U+ ?: H9 Y" _# p7 \* O0 Z8 c };
9 C0 [* H1 ?4 |. p A( Y$ j template
: H$ r! u/ t& @ TA::a;
# I* T8 r! R4 ~ intmain(intargc,char*argv[])
$ R8 S& d* W# o. e; w { 3 F' y; O" [; D3 Q
A::a=0;
8 V. f; F! m5 V" u }
0 @$ |* @5 E; G$ w7 G" q. Q. q */
* g! r1 L( C1 a& A intmain(intargc,char*argv[]) ! z' t% {/ U: ]& C/ C A" B3 ]7 X
{
" ^1 g0 c8 [# [9 f veclv1;
9 w1 U: p) N- Y# E7 S d5 w) | lv1.m_x=1; 8 H3 ~. m G3 |+ R5 }! h/ v
veclv2;
) V1 S% @, s0 z lv2.m_x=2; ) J8 z( _- P9 Y! L: h
cout《"countis"《lv1.GetAutolistCount()《endl; / K& R8 D# E T2 {# v8 {, j! x
vec*cptmp=lv2.GetAutolistFirst();
: O7 L9 H: [( I2 d( D% r i/ D while(cptmp) - A n. x9 x( P/ c1 z; v3 Y8 r, D
{
7 }, Q5 p; H. X4 {. T8 o$ e! n cout《"xis"《cptmp->m_x《endl; % v5 f9 r- S( Y; T& u
cptmp=lv2.GetAutolistNext();
2 X7 q+ y" q0 a O- t }
m6 B# l0 f* V4 G. t7 ` `3 c return(0); } |