c++中的泛型

#include


using std::cout;
using std::endl;
 
templateclass Test
{
       //冒泡排序
        public :static  void BubbleSort(T a[], int n)
        {
            int i, j;
            
            T temp;


            bool flag=false;


            for(i=n-1;i>=0;i--)
            {
              flag=false;


             for(j=0;j             {


              if (a[j + 1]             
              {
               temp=a[j+1]; a[j+1]=a[j]; a[j]=temp;




               flag=true;
              }


            }


             if(flag==false) break;


           }




        }   //end BubbleSort


 
    };   //end Test


              
 
   
         
          int main()
          {
              int i;          
           
              
              int a[5]={23,45,8,0,9};
              
             Test::BubbleSort(a,5);
         
         
              
              for(i=0;i<5;i++)std::cout<             
              
             system ("pause");


              return 0;
        

       }



代码是完全可以通过, 不用所谓接口,但是到了C#中,是无法通过的,提示:   if (a[j + 1]


这是为什么??


一个能通过。一个不能通过

你可能感兴趣的:(c++中的泛型)