C++ Function Return Dereferencing Return Value

Description

C++ Function Return Dereferencing Return Value

#include <iostream> 

using namespace std; 

string *readCode() /*from   w  ww  .ja v a 2 s . c o  m*/
{ 
  string *code = new string("ABCDEF"); 
  return code; 
} 

int main() 
{ 
  string newcode; 
  int index; 

  for (index = 0; index < 10; index++) 
  { 
    newcode = *readCode(); 
    cout << newcode << endl; 
  } 

  return 0; 
}



PreviousNext

Related