invalid conversion from 'char*' to 'char'

后端 未结 2 686
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-26 10:56

I\'m getting the error in the title. It\'s pointing to the line where the for-loop is declared. Any ideas on what is happening?

#include 

templa         


        
2条回答
  •  醉话见心
    2021-01-26 11:29

    In the line:

    for (T* i(arr+1), j(arr+n); i != j; ++i)
    

    Only the i is declared as pointer to T, j is declared as an instance of T. The correct declaration is:

    for (T* i(arr+1),* j(arr+n); i != j; ++i)
    

    And by the way, you should add include for strlen:

    #include 
    

提交回复
热议问题