C++ struct Storing an address in a structure member

Description

C++ struct Storing an address in a structure member

#include <iostream>
#include <iomanip>
using namespace std;
struct Test/*  w ww  .  j av a  2  s  . com*/
{
   int id;
   double *ptPay;
};
int main()
{
   Test emp;
   double pay = 456.20;
   emp.id = 12345;
   emp.ptPay = &pay;
   cout << setw(6) << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
   cout << "\nEmployee number " << emp.id << " was paid $" << *emp.ptPay << endl;
   return 0;
}



PreviousNext

Related