473,657 Members | 2,572 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(st ring 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 2303
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
7035
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 contains the program to execute (fop.bat with several parameters). But I'm getting the following error message :
1
2650
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 that says: 'There was a problem retrieving printer information for this object. The object may have been sent to a printer that was unavailable.' When I choose 'report wizard', I can go through all of the steps but then I get an error message...
4
1602
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
5780
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 new record to a subform. If I close msgbox I can then successfully add new record. Have looked on MS Technet and tried their 2 suggestions:- 1)LinkChildFields property contains the name of a form property - this isn't the case linkChildFields...
2
1245
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 had problems getting .aspx pages displayed so I ran: c:\winnt\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i regsvr32 c:\winnt\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll After a reboot I could see my .aspx pages loading with...
3
9688
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 cause? ************** Exception Text ************** System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies....
0
1756
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 namespace 'System' <are you missing an assembly reference> The Source Code:
4
3027
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 debugger unless I add a Global.asax file. When I do that and then try to run the debugger I receive error 403. If I remove the Global.asax file things work fine. The Global.asax file is the one generated by VS 2005 - I don't try to add anything...
10
5856
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 sample of the code i am using but when attempting to modify existing code or create a new page using this code i receive an error in the .Send line in IE. I will paste the error message when i return to work but basically states error executing...
0
8425
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8522
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8622
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
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 we have to send another system
2
1736
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.