3 Replies - 412 Views - Last Post: 02 February 2017 - 06:27 PM Rate Topic: -----

#1 MisterBungle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 31-January 17

no instance of overloaded function getline matches the arguement list

Posted 02 February 2017 - 04:49 PM

I've been trying to gain input from these two lines of code for quite some time now - whenever I use the get line operation I just receive the error "no instance of overloaded function getline matches the arguement list"

Here's the code so far - the errors are on line 58 and 64. The first time I used get line nothing went wrong but I entered it again 2 more times and received errors for some reason. I'm pretty sure the problem is just really obvious and I'm just overlooking it.

http://pastebin.com/n4ZJs2n3

PASTEBINnew pastetrends API tools faq
search...


Guest User
-

Public Pastes
Untitled
6 sec ago
Untitled
8 sec ago
Untitled
14 sec ago
Untitled
15 sec ago
Untitled
31 sec ago
Untitled
38 sec ago
Untitled
45 sec ago
Untitled
1 min ago

SHARE
TWEET

Untitled
A GUEST FEB 2ND, 2017 0 IN 1 DAY

Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
rawdownloadcloneembedreportprint text 3.29 KB
/*  Homework Lab 5
 
This lab practices prompting the user and reading input
from the keyboard, performing a simple calculation with
the input values, and displaying the results.
 
You were introduced to three different ways of reading characters
from a keyboard:
 
cin >> aVariable;
getline(cin, aStringVariable);
cin.get(aCharVar); -or- aCharVar = cin.get();
 
As you complete the steps below, think about which keyboard
input technique is appropriate for each piece of data. You
won't necessarily need to use each technique...
 
Complete each step following the 5 comments below to
produce the program interaction shown at the bottom
of the program listing (following main).
 
You MUST use ONLY the variables that are provided, you may NOT
create additional variables
 
*/
 
#include<iostream>
#include<string>
using namespace std;
 
int main()
{
    // Input variables
    string fullName;
    int hoursWorked;
    double payRate;
 
    double grossPay;     // Calculated gross pay
 
    // TODO: STEP 1:
    // Prompt the user on the screen to enter their name, and then
    // read what the user types on the keyboard as their name.
    // NOTE: You MUST read directly into the fullName variable provided
    // NOTE: Think about what technique is necessary to read different names:
    //       Mary
    //       Haywood J'Paymee
    //       Joe Smith, Jr.
    cout << "What is your name ?";
     getline(cin, fullName);
   
 
 
 
    // TODO: STEP 2:
    // Prompt the user on the screen to enter hours worked, and then
    // read from the keyboard what the user types as the hours worked.
    cout << "How many hours have you worked this week ?";
    getline(cin, hoursWorked);
   
    // TODO: STEP 3:
    // Prompt the user, and then
    // get the user's entry for hourly pay rate.
    cout << "How much do you earn per hour ?";
    getline(cin, payRate);
     
   
 
 
 
        // TODO: STEP 4:
        // Calculate the gross pay.
        // No screen prompt, no reading from the keyboard - just calculate
       grossPay = payRate*hoursWorked;
 
 
 
    // TODO: STEP 5:
    // Display the user's full name and
    // calculated gross pay as shown in
    // the sample program interaction below.
    //
    // There are three different interactions shown -
    // you will need to run the program three
    // different times to test each interaction.
   
    cout << "Enter your name:" << fullName << endl;
    cout << "Enter hours worked:"  << hoursWorked    << endl;
    cout << "Enter your hourly pay rate:" << payRate     << endl;
    cout << endl;
    cout << "Hello," << fullName << "!"      << endl;
    cout << "Your gross pay is" << grossPay   << endl;
 
   
 
    return 0;
}
 
/*  Sample program interactions (3 different tests, with different entries):
 
Test #1:
---------------------------------
Enter your name: Mary
Enter hours worked: 40
Enter your hourly pay rate: 22.50
 
Hello, Mary!
Your gross pay is $900
 
Press any key to continue . . .
 
Test #2:
---------------------------------
Enter your name: Haywood J'Paymee
Enter hours worked: 35
Enter your hourly pay rate: 20
 
Hello, Haywood J'Paymee!
Your gross pay is $700
 
Press any key to continue . . .
 
Test #3:
---------------------------------
Enter your name: Joe Smith, Jr.
Enter hours worked: 39
Enter your hourly pay rate: 15.33
 
Hello, Joe Smith, Jr.!
Your gross pay is $597.87
 
Press any key to continue . . .
 
*/
RAW Paste Data

/*  Homework Lab 5

This lab practices prompting the user and reading input
from the keyboard, performing a simple calculation with
the input values, and displaying the results.

You were introduced to three different ways of reading characters
from a keyboard:

cin >> aVariable;
getline(cin, aStringVariable);
cin.get(aCharVar); -or- aCharVar = cin.get();

As you complete the steps below, think about which keyboard
input technique is appropriate for each piece of data. You
won't necessarily need to use each technique...

Complete each step following the 5 comments below to
produce the program interaction shown at the bottom
of the program listing (following main).

You MUST use ONLY the variables that are provided, you may NOT
create additional variables

*/

#include<iostream>
#include<string>
using namespace std;

int main()
{
	// Input variables
	string fullName;
	int hoursWorked;
	double payRate;

	double grossPay;     // Calculated gross pay

	// TODO: STEP 1:
	// Prompt the user on the screen to enter their name, and then
	// read what the user types on the keyboard as their name.
	// NOTE: You MUST read directly into the fullName variable provided
	// NOTE: Think about what technique is necessary to read different names:
	//       Mary
	//       Haywood J'Paymee
	//       Joe Smith, Jr.
	cout << "What is your name ?";
	 getline(cin, fullName);
	



	// TODO: STEP 2:
	// Prompt the user on the screen to enter hours worked, and then
	// read from the keyboard what the user types as the hours worked.
	cout << "How many hours have you worked this week ?";
	getline(cin, hoursWorked);
	
	// TODO: STEP 3:
	// Prompt the user, and then
	// get the user's entry for hourly pay rate.
	cout << "How much do you earn per hour ?";
	getline(cin, payRate);
	 
   



		// TODO: STEP 4:
		// Calculate the gross pay.
		// No screen prompt, no reading from the keyboard - just calculate
	   grossPay = payRate*hoursWorked;



	// TODO: STEP 5:
	// Display the user's full name and
	// calculated gross pay as shown in
	// the sample program interaction below.
	//
	// There are three different interactions shown -
	// you will need to run the program three
	// different times to test each interaction.
	
	cout << "Enter your name:" << fullName << endl;
	cout << "Enter hours worked:"  << hoursWorked    << endl;
	cout << "Enter your hourly pay rate:" << payRate     << endl;
	cout << endl;
	cout << "Hello," << fullName << "!"      << endl;
	cout << "Your gross pay is" << grossPay   << endl;

	

	return 0;
}



/*  Sample program interactions (3 different tests, with different entries):

Test #1:
---------------------------------
Enter your name: Mary
Enter hours worked: 40
Enter your hourly pay rate: 22.50

Hello, Mary!
Your gross pay is $900

Press any key to continue . . .

Test #2:
---------------------------------
Enter your name: Haywood J'Paymee
Enter hours worked: 35
Enter your hourly pay rate: 20

Hello, Haywood J'Paymee!
Your gross pay is $700

Press any key to continue . . .

Test #3:
---------------------------------
Enter your name: Joe Smith, Jr.
Enter hours worked: 39
Enter your hourly pay rate: 15.33

Hello, Joe Smith, Jr.!
Your gross pay is $597.87

Press any key to continue . . .

*/

This post has been edited by snoopy11: 02 February 2017 - 08:51 PM
Reason for edit:: added [ CODE ] tags please learn to use them !


Is This A Good Question/Topic? 0
  • +

Replies To: no instance of overloaded function getline matches the arguement list

#2 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2015
  • View blog
  • Posts: 5,409
  • Joined: 27-December 05

Re: no instance of overloaded function getline matches the arguement list

Posted 02 February 2017 - 05:48 PM

getline expects a string as the second argument. On line 49 you gave it a string, fullName, so no error there. But on lines 58 and 64 you pass it an int and a double respectively, hence "no instance of overloaded function getline matches the argument list".
Was This Post Helpful? 0
  • +
  • -

#3 MisterBungle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 31-January 17

Re: no instance of overloaded function getline matches the arguement list

Posted 02 February 2017 - 06:13 PM

View Postr.stiltskin, on 02 February 2017 - 05:48 PM, said:

getline expects a string as the second argument. On line 49 you gave it a string, fullName, so no error there. But on lines 58 and 64 you pass it an int and a double respectively, hence "no instance of overloaded function getline matches the argument list".


So how would I go about changing the line but also taking the input from the user and outputting it to lines 87 and 88 ?
Was This Post Helpful? 0
  • +
  • -

#4 MisterBungle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 31-January 17

Re: no instance of overloaded function getline matches the arguement list

Posted 02 February 2017 - 06:27 PM

I'm stupid. I used the cin >> command that worked. Thanks for your help man - I was stuck pretty bad!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1