Search This Blog

Sunday, May 2, 2010

C++ User-Defined Vector

Programmer Question


How do you declare a vector in c++ while allowing user input to define the vector's name?
Okay, after reviewing your responses, here is more detail; Here is the error message from VS08 C++ console application -



Error 2 error C2664: 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::get(_Elem *,std::streamsize)' : cannot convert parameter 1 from 'std::istream' to 'char *' e:\c++\project 5\project 5\project 5.cpp 58 project 5


Here is the code:



void addRecord()
{
vector<char>recordName;
vector<inventory>recordNameUser;
cout << "Name the record you want to store it as\n";
cin.get(cin, recordName);
cout << "Enter the item description\n";
cin.get(cin, recordNameUser.itemDescription);
cout << "Enter the quanity on hand\n";
cin >> recordNameUser.quanityOnHand;
cout << "Enter the wholesale cost\n";
cin >> recordNameUser.wholesaleCost;
cout << "Enter the retail cost\n";
cin >> recordNameUser.retailCost;
cout << "Enter the date of the inventory (mm/dd/yyyy)\n";
cin >> recordNameUser.inventoryDate;
}




Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails