Link to home
Start Free TrialLog in
Avatar of mustish1
mustish1

asked on

Display the values

Hi guys: Can any one please tell me how to i display the values of name and salary in two separate functions ? Thanks.


#include<iostream>
using namespace test;
class Employee
{
      public:
            string name;
            double salary;

            Employee();
            Employee(string n, double s);
            void displayname();  // Display name
            void displaysalary();  // Display salary
           
};

Employee::Employee()
{
    name = "Andy Griffith Show";
    salary = 20000;
}

Employee::Employee(string n, double s)
{
  name = n;
  salary = s;

}

int main()
{
      system("pause");
      return 0;
}
Avatar of UltraDog
UltraDog
Flag of Israel image

use the "cout" or "printf" commands
for example:

void Employee::displayname()
{
    cout<"Employee's name:"<<name<<"\r\n"
}

void Employee::displaysalary()
{
    printf("Employee's salary: %f", salary);

}
Avatar of mustish1
mustish1

ASKER

Program runs but dont display any thing


#include<iostream>
using namespace test;
class Employee
{
      public:
            string name;
            double salary;

            Employee();
            Employee(string n, double s);
            void displayname();  // Display name
            void displaysalary();  // Display salary
           
};

Employee::Employee()
{
    name = "Andy Griffith Show";
    salary = 20000;
}

Employee::Employee(string n, double s)
{
  name = n;
  salary = s;

}

int main()
{
      system("pause");
      return 0;
}

void Employee::displayname()
{
    cout << "Employee's name:" << name << endl;
}

void Employee::displaysalary()
{
    cout << "Employee's salary:" << salary << endl;

}
ASKER CERTIFIED SOLUTION
Avatar of UltraDog
UltraDog
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks.