Declaring Pointers to Objects - C++ Class

C++ examples for Class:object

Description

Declaring Pointers to Objects

Demo Code

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

class Employee/*from   w  w w  . j  a v  a  2s  .c o  m*/
{
  public:
    int  workHour;
    double salary;
    double addWork(int hours, double grade){return 0.0;}
};

int main(int argc, char* pArgs[])
{
    Employee s;
    s.salary = 3.0;

    Employee* pS;

    pS = &s;

    cout << "s.salary   = " << s.salary   << "\n" << "pS->salary = " << pS->salary << endl;

    return 0;
}

Result


Related Tutorials