New Posts  All Forums:Forum Nav:

c++ problem

post #1 of 22
Thread Starter 
Code:
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

class Employee
{
public:
        Employee();
        Employee(string, string, char, int, double);
        double calculatePay();
        void displayEmployee(string,string, char, int, double);
        void getFirstName(string);
        void setFirstName(string &);
        void getLastName(string);
        void setLastName(string &);
        void getGender(char);
        void setGender(char &);
        void getDependents(int);
        void setDependents(int &);
        void getAnnualSalary(double);
        void setAnnualSalary(double &);

private:
        string first;
        string last;
        char gen;
        int dep;
        double salary;
};

Employee::Employee()
{
first = "";
last = "";
gen = 0;
dep = 0;
salary = 0;
}

Employee::Employee(string firstName,string lastName, char gender, int dependents, double annualSalary)
{
first = firstName;
last = lastName;
gen = gender;
dep = dependents;
salary = annualSalary;
}

double Employee::calculatePay()
{
        return salary / 52;
}

void Employee::displayEmployee(string firstName,string lastName, char gender, int dependents, double annualSalary)
{
first = firstName;
last = lastName;
gen = gender;
dep = dependents;
salary = annualSalary;
}

void Employee::getFirstName(string firstName)
{
first = firstName;
}

void Employee::setFirstName(string &firstName)
{
        firstName = first;
}

void Employee::getLastName(string lastName)
{
    last = lastName;
}

void Employee::setLastName(string &lastName)
{
        lastName = last;
}

void Employee::getGender(char gender)
{
        gen = gender;
}

void Employee::setGender(char &gender)
{
        gender = gen;
}

void Employee::getDependents(int dependents)
{
        dep = dependents;
}

void Employee::setDependents(int &dependents)
{
        dependents = dep;
}

void Employee::getAnnualSalary(double annualSalary)
{
        salary = annualSalary;
}

void Employee::setAnnualSalary(double &annualSalary)
{
        annualSalary = salary;
}

string getInput(string);
void DisplayApplicationInformation();
void DividerDisplay(string, string, char, int, double, double);
void TerminateApplication(char);

int main()
{
string input = "";
string firstName = "not given";
string lastName = "not given";
char gender = 'U';
int dependents = 0;
double annualSalary = 20000;
double CalculatePay = 0;
char exit = 0;

DisplayApplicationInformation ();

cout << "***************** Employee 1 *****************" << endl;
firstName = getInput("first name: ");
lastName = getInput("last name: ");
input = getInput("gender: ");
gender = input.at(0);
input = getInput("dependents: ");
dependents= atoi(input.c_str());
input = getInput("annual salary: ");
annualSalary = atof(input.c_str());
CalculatePay = annualSalary/52;


DividerDisplay(firstName, lastName, gender, dependents, annualSalary, CalculatePay);

cout << "***************** Employee 2 *****************" << endl;
cout << "Employee Information" << endl;
cout << "______________________________________________" << endl;

TerminateApplication(exit);

Employee employeeInfo(firstName, lastName, gender, dependents, annualSalary);
employeeInfo.displayEmployee(firstName, lastName, gender, dependents, annualSalary);


return 0;
}

void DisplayApplicationInformation()
{
cout << "Welcome the Basic User Interface Program" << endl;
cout << "CIS247, Week 2 Lab" << endl;
cout << "Name: " << endl;
}

void DividerDisplay(string firstName, string lastName, char gender, int dependents, double annualSalary, double CalculatePay)
{ 
        cout << " Employee Information" << endl;
        cout << "______________________________________________" << endl;
        cout << "First Name:" << firstName << endl;
        cout << "Last Name:" << lastName << endl;
        cout << "Gender:" << gender << endl;
        cout << "Dependents:" << dependents << endl;
        cout << "Annual Salary: \t" << setprecision(2) << showpoint << fixed << annualSalary << "\n" << endl;
        cout << "Weekly Pay: " << CalculatePay << endl;
}

string getInput(string inputType)
{
string strInput= "";
cout << "Please enter your " << inputType;
getline(cin, strInput);
return strInput;
}

void TerminateApplication(char exit)
{
cout << "Thank you for using the Basic User Interface program" << endl;
}


The thing is I can't get setter and gettter to work. need some help. Thanks
   
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
  hide details  
Reply
   
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
  hide details  
Reply
post #2 of 22
They should look like this:
Code:
int Class::getINT()
{
     return integer;
}

void Class::setINT(int x)
{
     integer = x;
}
v3.3.2
(15 items)
 
Dell Inspiron 15R
(13 items)
 
v2.2.6
(14 items)
 
CPUMotherboardGraphicsRAM
i5 3570K GIGABYTE GA-Z77X-UD5H NVIDIA GeForce GTX 970 G. SKILL Sniper 16GB (4GBx4) 
Hard DriveHard DriveHard DriveCooling
SanDisk Ultra II 120GB 2 x OCZ Vertex 4 256GB Seagate Barracuda 1TB Corsair H90 
OSMonitorKeyboardPower
Windows 8.1 Pro Dell Ultrasharp U2311H Logitech G510s Corsair AX750 
CaseMouseOther
NZXT Switch 810 Logitech G502 Proteus Spectrum APC BX1000G UPS 
CPUGraphicsRAMHard Drive
Intel i3 2350M Intel HD3000 6GB DDR3 Corsair Force 3 120GB SSD 
OSMonitor
Lion 15" 
CPUMotherboardGraphicsRAM
AMD FX-8120 @ 4.4GHz ASUS SABERTOOTH 990FX XFX Radeon HD 5870 G. SKILL Sniper 8GB (4GBx2) @ 2133MHz 
Hard DriveCoolingOSMonitor
Seagate Barracuda 1TB Corsair H80 Windows 7 x64 Acer x193w+ 
KeyboardPowerCaseMouse
Logitech K800 PC Power & Cooling 910w Silencer Lian-Li ARMORSUIT PC-P50 Logitech Performance MX 
  hide details  
Reply
v3.3.2
(15 items)
 
Dell Inspiron 15R
(13 items)
 
v2.2.6
(14 items)
 
CPUMotherboardGraphicsRAM
i5 3570K GIGABYTE GA-Z77X-UD5H NVIDIA GeForce GTX 970 G. SKILL Sniper 16GB (4GBx4) 
Hard DriveHard DriveHard DriveCooling
SanDisk Ultra II 120GB 2 x OCZ Vertex 4 256GB Seagate Barracuda 1TB Corsair H90 
OSMonitorKeyboardPower
Windows 8.1 Pro Dell Ultrasharp U2311H Logitech G510s Corsair AX750 
CaseMouseOther
NZXT Switch 810 Logitech G502 Proteus Spectrum APC BX1000G UPS 
CPUGraphicsRAMHard Drive
Intel i3 2350M Intel HD3000 6GB DDR3 Corsair Force 3 120GB SSD 
OSMonitor
Lion 15" 
CPUMotherboardGraphicsRAM
AMD FX-8120 @ 4.4GHz ASUS SABERTOOTH 990FX XFX Radeon HD 5870 G. SKILL Sniper 8GB (4GBx2) @ 2133MHz 
Hard DriveCoolingOSMonitor
Seagate Barracuda 1TB Corsair H80 Windows 7 x64 Acer x193w+ 
KeyboardPowerCaseMouse
Logitech K800 PC Power & Cooling 910w Silencer Lian-Li ARMORSUIT PC-P50 Logitech Performance MX 
  hide details  
Reply
post #3 of 22
Quote:
Originally Posted by Futan View Post

They should look like this:
Code:
int Class::getINT()
{
     return integer;
}
void Class::setINT(int x)
{
     integer = x;
}

This. smile.gif

You want to be returning some value for the "get" functions. Right now your "get" actually is "set".

Edit: Looked more closely. I think you might want to review how classes and passing args by reference work!
Current
(12 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASRock Z68 Extreme4 Gen3 EVGA GTX 570 Classified 4x4GB Corsair XMS3 
Hard DriveCoolingPowerCase
Samsung 830 Thermaltake Frio OCZ ZS 850W Lian Li Lancool First Knight K9 
MouseAudioOtherOther
Logitech G500 Audinst HUD-MX1 Sennheiser HD598 Swan D1080MkII 
  hide details  
Reply
Current
(12 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k ASRock Z68 Extreme4 Gen3 EVGA GTX 570 Classified 4x4GB Corsair XMS3 
Hard DriveCoolingPowerCase
Samsung 830 Thermaltake Frio OCZ ZS 850W Lian Li Lancool First Knight K9 
MouseAudioOtherOther
Logitech G500 Audinst HUD-MX1 Sennheiser HD598 Swan D1080MkII 
  hide details  
Reply
post #4 of 22
Thread Starter 
Thanks guys.. let me work on it.. sorry beginner coder here.. im taking this class right now and have to finish this code until 11pm later...
   
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
  hide details  
Reply
   
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
  hide details  
Reply
post #5 of 22
Thread Starter 
Am i doing it right?
Quote:
string Employee::getFirstName(string)
{
return first;
}

void Employee::setFirstName(string &firstName)
{
first =firstName;
}
   
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
  hide details  
Reply
   
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
  hide details  
Reply
post #6 of 22
Quote:
Originally Posted by adamski07 View Post

Am i doing it right?
Quote:
string Employee::getFirstName(string)
{
return first;
}
void Employee::setFirstName(string &firstName)
{
first =firstName;
}

It will work, but there's no need for the ampersand.

edit: Oh, and you don't want the string in Getter.
v3.3.2
(15 items)
 
Dell Inspiron 15R
(13 items)
 
v2.2.6
(14 items)
 
CPUMotherboardGraphicsRAM
i5 3570K GIGABYTE GA-Z77X-UD5H NVIDIA GeForce GTX 970 G. SKILL Sniper 16GB (4GBx4) 
Hard DriveHard DriveHard DriveCooling
SanDisk Ultra II 120GB 2 x OCZ Vertex 4 256GB Seagate Barracuda 1TB Corsair H90 
OSMonitorKeyboardPower
Windows 8.1 Pro Dell Ultrasharp U2311H Logitech G510s Corsair AX750 
CaseMouseOther
NZXT Switch 810 Logitech G502 Proteus Spectrum APC BX1000G UPS 
CPUGraphicsRAMHard Drive
Intel i3 2350M Intel HD3000 6GB DDR3 Corsair Force 3 120GB SSD 
OSMonitor
Lion 15" 
CPUMotherboardGraphicsRAM
AMD FX-8120 @ 4.4GHz ASUS SABERTOOTH 990FX XFX Radeon HD 5870 G. SKILL Sniper 8GB (4GBx2) @ 2133MHz 
Hard DriveCoolingOSMonitor
Seagate Barracuda 1TB Corsair H80 Windows 7 x64 Acer x193w+ 
KeyboardPowerCaseMouse
Logitech K800 PC Power & Cooling 910w Silencer Lian-Li ARMORSUIT PC-P50 Logitech Performance MX 
  hide details  
Reply
v3.3.2
(15 items)
 
Dell Inspiron 15R
(13 items)
 
v2.2.6
(14 items)
 
CPUMotherboardGraphicsRAM
i5 3570K GIGABYTE GA-Z77X-UD5H NVIDIA GeForce GTX 970 G. SKILL Sniper 16GB (4GBx4) 
Hard DriveHard DriveHard DriveCooling
SanDisk Ultra II 120GB 2 x OCZ Vertex 4 256GB Seagate Barracuda 1TB Corsair H90 
OSMonitorKeyboardPower
Windows 8.1 Pro Dell Ultrasharp U2311H Logitech G510s Corsair AX750 
CaseMouseOther
NZXT Switch 810 Logitech G502 Proteus Spectrum APC BX1000G UPS 
CPUGraphicsRAMHard Drive
Intel i3 2350M Intel HD3000 6GB DDR3 Corsair Force 3 120GB SSD 
OSMonitor
Lion 15" 
CPUMotherboardGraphicsRAM
AMD FX-8120 @ 4.4GHz ASUS SABERTOOTH 990FX XFX Radeon HD 5870 G. SKILL Sniper 8GB (4GBx2) @ 2133MHz 
Hard DriveCoolingOSMonitor
Seagate Barracuda 1TB Corsair H80 Windows 7 x64 Acer x193w+ 
KeyboardPowerCaseMouse
Logitech K800 PC Power & Cooling 910w Silencer Lian-Li ARMORSUIT PC-P50 Logitech Performance MX 
  hide details  
Reply
post #7 of 22
Thread Starter 
but that's what we should use. what wrong with string in getter?
   
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
  hide details  
Reply
   
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
  hide details  
Reply
post #8 of 22
Quote:
Originally Posted by adamski07 View Post

but that's what we should use. what wrong with string in getter?

I just mean the bolded part. Sorry. In the parenthesis'(the arguments) is what the caller will be sending to the function for use. Since you're just getting information from the Getter function, and not sending any to it, you don't want any arguments.
v3.3.2
(15 items)
 
Dell Inspiron 15R
(13 items)
 
v2.2.6
(14 items)
 
CPUMotherboardGraphicsRAM
i5 3570K GIGABYTE GA-Z77X-UD5H NVIDIA GeForce GTX 970 G. SKILL Sniper 16GB (4GBx4) 
Hard DriveHard DriveHard DriveCooling
SanDisk Ultra II 120GB 2 x OCZ Vertex 4 256GB Seagate Barracuda 1TB Corsair H90 
OSMonitorKeyboardPower
Windows 8.1 Pro Dell Ultrasharp U2311H Logitech G510s Corsair AX750 
CaseMouseOther
NZXT Switch 810 Logitech G502 Proteus Spectrum APC BX1000G UPS 
CPUGraphicsRAMHard Drive
Intel i3 2350M Intel HD3000 6GB DDR3 Corsair Force 3 120GB SSD 
OSMonitor
Lion 15" 
CPUMotherboardGraphicsRAM
AMD FX-8120 @ 4.4GHz ASUS SABERTOOTH 990FX XFX Radeon HD 5870 G. SKILL Sniper 8GB (4GBx2) @ 2133MHz 
Hard DriveCoolingOSMonitor
Seagate Barracuda 1TB Corsair H80 Windows 7 x64 Acer x193w+ 
KeyboardPowerCaseMouse
Logitech K800 PC Power & Cooling 910w Silencer Lian-Li ARMORSUIT PC-P50 Logitech Performance MX 
  hide details  
Reply
v3.3.2
(15 items)
 
Dell Inspiron 15R
(13 items)
 
v2.2.6
(14 items)
 
CPUMotherboardGraphicsRAM
i5 3570K GIGABYTE GA-Z77X-UD5H NVIDIA GeForce GTX 970 G. SKILL Sniper 16GB (4GBx4) 
Hard DriveHard DriveHard DriveCooling
SanDisk Ultra II 120GB 2 x OCZ Vertex 4 256GB Seagate Barracuda 1TB Corsair H90 
OSMonitorKeyboardPower
Windows 8.1 Pro Dell Ultrasharp U2311H Logitech G510s Corsair AX750 
CaseMouseOther
NZXT Switch 810 Logitech G502 Proteus Spectrum APC BX1000G UPS 
CPUGraphicsRAMHard Drive
Intel i3 2350M Intel HD3000 6GB DDR3 Corsair Force 3 120GB SSD 
OSMonitor
Lion 15" 
CPUMotherboardGraphicsRAM
AMD FX-8120 @ 4.4GHz ASUS SABERTOOTH 990FX XFX Radeon HD 5870 G. SKILL Sniper 8GB (4GBx2) @ 2133MHz 
Hard DriveCoolingOSMonitor
Seagate Barracuda 1TB Corsair H80 Windows 7 x64 Acer x193w+ 
KeyboardPowerCaseMouse
Logitech K800 PC Power & Cooling 910w Silencer Lian-Li ARMORSUIT PC-P50 Logitech Performance MX 
  hide details  
Reply
post #9 of 22
Thread Starter 
but how am I gonna call the getter and set a value for it?
   
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
  hide details  
Reply
   
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
CPUMotherboardGraphicsGraphics
Intel 4770K Asus ROG Maximus Formula VI EVGA GTX 980 SC EVGA GTX 980 SC 
RAMHard DriveHard DriveHard Drive
Corsair Vengenace PRO Western Digital Seagate Samsung 830 SSD 
Hard DriveCoolingOSMonitor
Plextor M5S SSD Aqua-Computer Windows 7 Ultiamte Asus ROG Swift PG278Q 
MonitorKeyboardPowerCase
Asus VS247H-P CoolerMaster QuickFire Pro CoolerMaster V850 CoolerMaster Storm Troope(Modified) 
MouseMouse PadAudioAudio
Razer Mamba Razer Vespula Bose Acoustimass 5.1 Setup Astro A40 
  hide details  
Reply
post #10 of 22
Not exactly sure what you mean. You don't want to set a value with the Getter, only get one. The Setter is what you want to use to set values, which does have an argument passed to it. I'm sure this will be frowned upon but apparently I'm too tired to explain things, lol so I'm just going to do this for you.
Code:
string getFirstName();
 void setFirstName(string);
string getLastName();
 void setLastName(string);
char getGender(;
 void setGender(char);
 int getDependents();
 void setDependents(int);
 double getAnnualSalary();
 void setAnnualSalary(double);

Employee::Employee(string firstName,string lastName, char gender, int dependents, double annualSalary)
 {
 first = firstName;
 last = lastName;
 gen = gender;
 dep = dependents;
 salary = annualSalary;
 } 

 /* void Employee::displayEmployee(string firstName,string lastName, char gender, int dependents, double annualSalary)
 {
 first = firstName;
 last = lastName;
 gen = gender;
 dep = dependents;
 salary = annualSalary;
 } */  NOT POSSIBLE. Use the individual Getters.

string Employee::getFirstName()
 {
return first;
 }

 void Employee::setFirstName(string firstName)
 {
 first = firstName;
 }

string Employee::getLastName()
 {
return last;
 }

 void Employee::setLastName(string lastName)
 {
 last = lastName;
 }

char Employee::getGender()
 {
 return gen;
 }

 void Employee::setGender(char gender)
 {
gen = gender;
 }

int Employee::getDependents()
 {
 return dep;
 }

 void Employee::setDependents(int dependents)
 {
 dep = dependents;
 }

double Employee::getAnnualSalary()
 {
 return salary;
 }

 void Employee::setAnnualSalary(double annualSalary)
 {
salary =  annualSalary;
 }

Put everything where it belongs and it'll work. As said in the code, displayEmployee is not possible. You'll need to use the individual Getters.

edit: If you want, in the morning I'll explain things.
Edited by Futan - 1/15/12 at 1:32am
v3.3.2
(15 items)
 
Dell Inspiron 15R
(13 items)
 
v2.2.6
(14 items)
 
CPUMotherboardGraphicsRAM
i5 3570K GIGABYTE GA-Z77X-UD5H NVIDIA GeForce GTX 970 G. SKILL Sniper 16GB (4GBx4) 
Hard DriveHard DriveHard DriveCooling
SanDisk Ultra II 120GB 2 x OCZ Vertex 4 256GB Seagate Barracuda 1TB Corsair H90 
OSMonitorKeyboardPower
Windows 8.1 Pro Dell Ultrasharp U2311H Logitech G510s Corsair AX750 
CaseMouseOther
NZXT Switch 810 Logitech G502 Proteus Spectrum APC BX1000G UPS 
CPUGraphicsRAMHard Drive
Intel i3 2350M Intel HD3000 6GB DDR3 Corsair Force 3 120GB SSD 
OSMonitor
Lion 15" 
CPUMotherboardGraphicsRAM
AMD FX-8120 @ 4.4GHz ASUS SABERTOOTH 990FX XFX Radeon HD 5870 G. SKILL Sniper 8GB (4GBx2) @ 2133MHz 
Hard DriveCoolingOSMonitor
Seagate Barracuda 1TB Corsair H80 Windows 7 x64 Acer x193w+ 
KeyboardPowerCaseMouse
Logitech K800 PC Power & Cooling 910w Silencer Lian-Li ARMORSUIT PC-P50 Logitech Performance MX 
  hide details  
Reply
v3.3.2
(15 items)
 
Dell Inspiron 15R
(13 items)
 
v2.2.6
(14 items)
 
CPUMotherboardGraphicsRAM
i5 3570K GIGABYTE GA-Z77X-UD5H NVIDIA GeForce GTX 970 G. SKILL Sniper 16GB (4GBx4) 
Hard DriveHard DriveHard DriveCooling
SanDisk Ultra II 120GB 2 x OCZ Vertex 4 256GB Seagate Barracuda 1TB Corsair H90 
OSMonitorKeyboardPower
Windows 8.1 Pro Dell Ultrasharp U2311H Logitech G510s Corsair AX750 
CaseMouseOther
NZXT Switch 810 Logitech G502 Proteus Spectrum APC BX1000G UPS 
CPUGraphicsRAMHard Drive
Intel i3 2350M Intel HD3000 6GB DDR3 Corsair Force 3 120GB SSD 
OSMonitor
Lion 15" 
CPUMotherboardGraphicsRAM
AMD FX-8120 @ 4.4GHz ASUS SABERTOOTH 990FX XFX Radeon HD 5870 G. SKILL Sniper 8GB (4GBx2) @ 2133MHz 
Hard DriveCoolingOSMonitor
Seagate Barracuda 1TB Corsair H80 Windows 7 x64 Acer x193w+ 
KeyboardPowerCaseMouse
Logitech K800 PC Power & Cooling 910w Silencer Lian-Li ARMORSUIT PC-P50 Logitech Performance MX 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming