+ Reply to Thread
Results 1 to 2 of 2

Thread: Can I use 'auto' keyword as a function argument?

  1. #1

    Can I use 'auto' keyword as a function argument?

    Can I use 'auto' keyword as a function argument?

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    109
    No, you cannot use 'auto' keyword as an argument of a function.

    Example:

    Code:
    /*
    void GiveMeAutoKeyword(auto nInteger) //'auto': a parameter cannot have a type that contains 'auto'
    {
    	char szMessage[100] ;
    	sprintf_s(szMessage, "Value = %d", nInteger) ;	
    }
    */
    
    template <typename T>
    void GiveMeTemplateArgument(T nInteger) //'auto': a parameter cannot have a type that contains 'auto'
    {
    	char szMessage[100] ;
    	sprintf_s(szMessage, "Value = %d", nInteger) ;	
    }
    Instead you can use function template to get same effect.

    Note:
    For more information : http://msdn.microsoft.com/en-us/library/dd293671.aspx

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts