+ Reply to Thread
Results 1 to 2 of 2

Thread: What is 'decltype' keyword in C++0x?

  1. #1

    What is 'decltype' keyword in C++0x?

    What is 'decltype' keyword in C++0x?

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    109
    The decltype type specifier for querying the type of a specified expression.

    Example:

    Code:
    void UseDeclType()
    {
    	int nInteger = 42 ;
    	char szMessage[100] ;
    	sprintf_s(szMessage, "Value = %d", nInteger) ;
    
    	decltype(nInteger) nAnotherInteger = 24 ; //this is like decltype(nInteger) = typeof(nInteger) = int!
    	sprintf_s(szMessage, "Value = %d", nAnotherInteger) ;
    
    	int &nReference = nInteger ;
    	nReference = 102 ;
    
    	sprintf_s(szMessage, "Value = %d", nReference) ;
    	sprintf_s(szMessage, "Value = %d", nInteger) ;
    
    	decltype(nReference) nAnotherReference = nAnotherInteger ;
    
    	nAnotherReference = 27 ;
    
    	sprintf_s(szMessage, "Value = %d", nAnotherReference) ;
    	sprintf_s(szMessage, "Value = %d", nAnotherInteger) ;
    }

+ 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