[Error] cannot convert 'std::vector<std::basic_string<char> >' to 'std::string*'


Hey guys, I am getting an error and I have no idea what is causing it

[Error] cannot convert 'std::vector<std::basic_string<char> >' to 'std::string*'

Here is the Code I am working with

Function Prototype:
 
int getInventory (string u[], int v[], double w[], double x[], int y[]); //getInventory Function Prototype 


Variables:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main()
{
	//declare variables
	
	int choice;  //holds the menu choice the user entered
	string itemIDEntered; //holds the itemID the user enters to search for in choice 1
	string itemIDToSell; //holds the itemID the user enters to sell in choice 2
	vector<string> itemID(2);
	vector<string> itemName(2);
	vector<int> pOrdered(2);
	vector<int> pInStore(2);
	vector<int> pSold(2);
	vector<double> manufPrice(2);
	vector<double> sellingPrice(2);


Function CALL:
getInventory(itemName, itemID, manufPrice, sellingPrice, pInStore); // Calls getInventory Function

FuNction:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// BEGIN getInventory Function
//	int getInventory (string u[], int v[], double w[], double x[], int y[])
int getInventory (string u[], int v[], double w[], double x[], int y[])

/* 
	itemName = U
	itemID = V
	manufPrice = W
	sellingPrice = X
	pInStore = Y
*/
{
	//Calling the File into the Program.
		ifstream inData;
			inData.open ("input.txt");
	
	//Check If file exists		
	if (inData)
	{

			//controlling the appearance of cout.
			cout << setprecision(2) << fixed << showpoint;
			
			//Updating the Array with each of the appropriate Values.
			int i;
			for (i = 0; i < 5; i++)
				{
				inData >> u[i] >> v[i] >> w[i] >> x[i] >> y[i];
				//cout << endl;
				
				/* Outputs Array Values
				
				cout <<" " << u[i] << " " << v[i] << " " << "$" << w[i] << " " << "$" << x[i] << " " << y[i];
				cout << endl << endl;
				
				*/
				}
				return 0;
	}
	
		// Display file !FOUND statement.
		else
			{
			cout << endl << endl;
			cout << "Sorry, the file does not exist. Please Check File Directory" << endl;
			return 1;
			}
}
// END getInventory function by (DL). 
Last edited on
Now I think I understand that it is telling me that it cannot convert a vector into a string -- but I am not sure what is causing it to try.

I can only assume that my string value is not in the vector format -- but when I change the header file to vector<string> it says something like...

"cannot convert vectort<string> to vector<string>"
u is declared as a pointer to string but you are passing a vector of strings.
Peter87, when I change the header file to
int getInventory (vector<string> u[], int v[], double w[], double x[], int y[])

The Problem persists...

Your Thoughts?
Remove the [] if you don't want u to be a pointer.
Last edited on
Different Problem, updated Code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

// BEGIN DL's function prototypes
	int getInventory (vector<string> u/*[]*/, int v[], double w[], double x[], int y[]); //getInventory Function Prototype
	
// END DL's function prototypes


int main()
{
	//declare variables
	
	int choice;  //holds the menu choice the user entered
	string itemIDEntered; //holds the itemID the user enters to search for in choice 1
	string itemIDToSell; //holds the itemID the user enters to sell in choice 2
	vector<string> itemID(2);
	vector<string> itemName(2);
	vector<int> pOrdered(2);
	vector<int> pInStore(2);
	vector<int> pSold(2);
	vector<double> manufPrice(2);
	vector<double> sellingPrice(2);

	ifstream infile;
	
	
// BEGIN getInventory Function call (DL)
		 getInventory(itemName, itemID, manufPrice, sellingPrice, pInStore); // Calls getInventory Function
		 
// END getInventory Function call (DL)

// BEGIN getInventory Function
//	int getInventory (string u[], int v[], double w[], double x[], int y[])
int getInventory (vector<string> u/*[]*/, int v[], double w[], double x[], int y[])

/* 
	itemName = U
	itemID = V
	manufPrice = W
	sellingPrice = X
	pInStore = Y
 */
I'm not sure what the new error is, but it might be a mismatch on the second parameter?

int getInventory (vector<string> u/*[]*/, int v[], double w[], double x[], int y[]);

vector<string> itemID(2);

getInventory(itemName, itemID, manufPrice, sellingPrice, pInStore); // Calls getInventory Function
Topic archived. No new replies allowed.