1 Replies - 635 Views - Last Post: 30 October 2012 - 11:55 AM Rate Topic: -----

#1 blue5476  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 29-October 12

compiler says "no instance of overloaded function 'getline

Posted 30 October 2012 - 10:15 AM

I ran this code last night fine but today I am getting an

"<IntelliSense: no instance of overloaded function "getline" matches the argument list c:\users\colleenr\documents\visual studio 2010\projects\tryit5b.cpp 29>"

So what could be overloading my fuinction?
//This program will collect 10 test scores and then tell the user how many of them were perfect.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


 
void enter();

class InvBin
 {
 private:
 string description; //Item name
 int qty; //qty of items in this bin

 public: InvBin (string d = "empty", int q = 0) //2-parameter constructor
 { description = d; qty = q; }

//with default values
 

//public member functions that will be used by the BinManger class, not the client program
 

void setDescription(string d)
 {		cout << " is currently " << description << "."
        << "\nPlease enter a description for your item: ";
		getline(cin, description); }

 string getDescription()
 { string d = description; 
return d; }
 

void setQty(int q)
 {	cout << "\nWhat quantity of " << description << "'s will be put into this bin?";
	cin >> qty; }
 

int getQty()
 { 
	int q = qty; 
	return q; };
 

void showInfo()
 { cout << description << " qty." << qty; };
 

int addInv(int num)
 { qty += num; 


return qty; };
 
};
  
  
 class BinManager
 {
 private:
 InvBin bin[30]; //Array of InvBin objects
 int numBins; 

public
	string name;
	int amount;
 
	BinManager()
	{ numBins = 0; }

//Default constructor
 
	BinManager(int size) //3-parameter constructor
	{ numBins = size; } 



//class public member functions
 string getDescription(int index) //returns name of one item
 { 

for (index = 0; index < numBins; index++)
 {	cout << "\nBin #" << index + 1;
	bin[index].setDescription(name);
	bin[index].getDescription(); 
}
 

return name; 
}

 string showDescription(int index) //returns name of one item
 { 

for (index = 0; index < numBins; index++)
 {	cout << "\nBin #" << index + 1;
	bin[index].showInfo();
 
}
 

return name; 
}
 

int getQuantity(int index) //returns qty of one item
 { 

for (int count2 = 0; count2 < numBins; count2++)
 { bin[count2].setQty(amount);
 bin[count2].getQty(); 

cin.get(); }
 

return amount;
 }
 

void displayAllBins(int index)
 { 

	for (int count = 0; count < numBins; count++)
	{ cout << fixed << left << "#" << count + 1 << " " << setw(20);
	  cout << bin[count].getDescription();
	  cout << " " << bin[count].getQty() << endl;
	}


}
 
int invMenu()
 { 


int choice;
 

int binChoice = 0;
 cout << "\n\nPlease choose from the menu below:\n"
      << "1.) Add to inventory \n"
	  << "2.) Subtract from inventory \n"
	  << "3.) Quit \n";
 cin >> choice;
 

if (choice == 1)
 { cout << "\nYou chose to add to your inventory.\n"
		<< "Please select the Bin # that you would like update: ";
    cin >> binChoice; }
 

else if ( choice == 2)
 { cout << "You chose to subtract from your inventory.\n"
 << "Please select the Bin # that you would like update: ";
 cin >> binChoice; }
 

else
 { cout << "You chose to quit the program. Have a nice day!\n"; }
 

return binChoice;
 }
 

//these return true if the action was done and false if it could not be done see validation info
 

int addParts(int binIndex)
 { 

	int addNum, total = 0;
	string name;
 
	cout << "\nHow many " << bin[binIndex-1].getDescription() << " would you like to add: ";
	cin >> addNum;
  
	bin[binIndex].addInv(addNum);
 


	return 0;
 }
  
 bool removeParts(int binIndex, int q);
 

};
 

const int MAX_BINS = 30;
void enter();
 
int main()
 {
 

int binSize,
 qty = 0,
 choice = 0;
 string desc;
 

	cout << "How many bins are you going to use: ";
	cin >> binSize;
	cin.get();
	 

const int BIN_NUM = binSize;
 

 
 BinManager wareHouse(binSize);
  
 wareHouse.getDescription(binSize);
 wareHouse.getQuantity(binSize); 


enter();
 system ("cls");
 
cout << "-------- WAREHOUSE INVENTORY --------\n";
 
	wareHouse.displayAllBins(binSize); 
 
	choice = wareHouse.invMenu();
	wareHouse.addParts(choice);
	wareHouse.displayAllBins(binSize); 

return 0;
 }
  
 void enter()
 {
 string temp; 
cout << "\nPress Enter."; 
temp = cin.get(); 
}


Is This A Good Question/Topic? 0
  • +

Replies To: compiler says "no instance of overloaded function 'getline

#2 jimblumberg  Icon User is offline

  • member icon


Reputation: 3845
  • View blog
  • Posts: 11,749
  • Joined: 25-December 09

Re: compiler says "no instance of overloaded function 'getline

Posted 30 October 2012 - 11:55 AM

A couple of things. First never open a C/C++ source file in a Word Processor. These programs insert all kinds of "special" characters that will not be understood by your compiler. Second you need to find an indentation style you like and use is consistently. Third you seem to have a missing colon after one of your public statements in one your classes.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1