473,507 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i get error c2886( when i use using std::cout; using std::string;) i change to using

3 New Member
i get error c2886( when i use using std::cout; using std::string;) and when i change to (using namespace std;
using namespace std;) i got error c2059

#include <iostream>
#include <string>
#include "Vector.h"
#include "Car.h"
//using namespace std::cout;
//using namespace std::string;
using namespace std;
using namespace std;

class Inventory {
public:
Inventory()
{
}

bool isExist(string const& vin)
{
for (int i = 0; i < data.size(); i++)
if (data.get(i)->getVIN() == vin)
return true;

return false;
}

void addRecord(Car* record)
{
if (data.size() < 20)
{
bool found = false;
for (int i=0; i < data.size() && !found; i++)
if (data.get(i) == record)
found = true;

if (!found && record->getYear() > 1980)
data.push_back(record);
else if (found)
cout << "Existing Record: " << *record << " not added!\n";
}
else
cout << "Inventory Full:" << *record << "!\n";
}

void removeRecord(string const& vin)
{
if (data.size() > 0)
{
if( isExist(vin)) {
for(int i=0; i<data.size(); i++)
if( data.get(i)->getVIN() == vin)
{
data.erase(i);
cout << "Car removed successfully!\n";
break;
}
} else
cout << "Car not found.\n";
}
else
cout << "No record in the inventory!\n";
}

void showRecords()
{
if (data.size()>0 )
{
for(int i=0; i<data.size(); i++)
{
cout << *data.get(i) << "\n";
}
}
else
cout << "No record in the inventory!\n";
}

void showRecords(int year, string const& model)
{
if (data.size()>0 )
{
for(int i=0; i<data.size(); i++)
{
if (data.get(i)->getYear() == year && data.get(i)->getModel() == model)
cout << *data.get(i) << "\n";
}
}
else
cout << "No record in the inventory!";
}

private:
Vector<Car> data;
};
May 3 '10 #1
2 2290
jkmyoung
2,057 Recognized Expert Top Contributor
Have you defined how cout is supposed to handle a Car object?
Perhaps you want a function in Car like
string GetInfo();

Then you could write:
cout << record.GetInfo();
May 3 '10 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
It would be better to write a series of member functions that return const pointers or referecnes toi the member data. That way you can format the display many different ways instead of one.

If there is only one display format, I would write an operator<< rather than an accessor function.
May 3 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
7030
by: Patrice FRITSCH | last post by:
I'm trying to run a batch file from an asp page using WScript.Shell object. Dim oWSH set oWSH= Server.CreateObject("WScript.Shell") call oWSH.Run("cmd.exe /c " & szCmd , 0, true) szCmd...
1
2634
by: intl04 | last post by:
I am getting strange print-related error messages when trying to create (not print!) reports. For example, when I click 'new' to create a report then choose 'design view', I get an error message...
4
1592
by: David | last post by:
The statement works fine when I use it in Access, but when I use it from VB, I get the error "Undefined function 'Nz' in expression." Could anyone please explain how to correct this? Thank you.
2
5762
by: brenda.stow | last post by:
error msg " An error occured while referencing the object. You tried to run a visual basic procedure that improperly references a property or method of an object" This msg occurs everytime I add a...
2
1242
by: Timbit | last post by:
Hi, this is probably an old question, and I have had no luck finding answers to this one on the internet that has helped me out. I installed VS .NET 2003, then I installed IIS 5.1 after that. I...
3
9683
by: Benny Raymond | last post by:
I get the following error message when trying to use the Excel Interop on my wife's machine however I don't get it on my own - we have the same version of Office installed - what could be the...
0
1740
by: Ramesh2006 | last post by:
Hi, The following error occurred when i programmatically compile another project from my present project. The Error: error CS0234:The type or namespace name 'Windows' does not exist in the...
4
3019
by: Al Santino | last post by:
Hello, I've created a simple C# web services project using Visual Studio 2005. My service compiles and runs correctly when called by remote clients. I'm able to step through the service in the...
10
5827
by: surferj | last post by:
I am beginning to receive an error message when trying to execute the .Send command when using the CDO.Configuration and CDO.Message in a W2k3 server environment on WXP machines and IE6. Below is a...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7034
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.