class test
{
private:
    int  a;
    char b;public int GetValue(int Type)
{
    int _r=defaultValue;
    switch(Type)    
    { 
      case 1:
          _r=a;
          break;
      case 2:
          _r=b;
          break;
    }
    return _r;
}
}

解决方案 »

  1.   

    class test
    {
    private:
        int  a;
        char b;public int GetValue(int Type)
    {
        switch(Type)    
        { 
          case 1:
              return a;
              break;
          case 2:
              return b;
              break;
        }
    }
    }
      

  2.   

    楼上的兄弟们
    如果我在多个string 类型的,怎么处理呢?不好意思忘了int 和char是相通的
      

  3.   

    比如下面的能实现吗,通过怎样的调整才能实现呢 ?
    class test
    {
    private:
        int  a;
        char b;
        string c;public GetValue(int Type)
    {
        switch(Type)    
        { 
          case 1:
              return a;
              break;
          case 2:
              return b;
              break;
          case 3:
              return c;
              break;
        }
    }
    }
      

  4.   

    因该使用.Net 1.1版的泛型
      

  5.   

    http://www.microsoft.com/china/msdn/library/dv_vstechart/html/vbconCProgrammingLanguageFutureFeatures.asp