Ok.. those 2 problems.. now I have 2 more.. I can already tell this language is going to be a pain in the ass
New code:
#include <iostream.h>#include <fstream.h>#include <string.h>#include "item2.h"StockItem::StockItem(): m_InStock(0), m_Price(0), m_Name(), m_Distributor(), m_UPC(){}StockItem::StockItem(char Name[50], short InStock, short Price, char Distributor[100], char UPC[35]): m_InStock(InStock), m_Price(Price), m_Name(Name), m_Distributor(Distributor), m_UPC(UPC){ }void StockItem::Read(ifstream& s) { s >> m_Name; s >> m_InStock; s >> m_Price; s >> m_Distributor; s >> m_UPC;}void StockItem::Display(){ cout << "Name: " << m_Name << endl; }int main(){ ifstream s_Inventory("inventory1.inv"); StockItem AllItems[100]; short i, InvCount; for(i=0; i<100; i++) { AllItems[i].Read(s_Inventory); if (s_Inventory.fail() != 0) break; } InvCount = i; for(i=0; i < InvCount; i++) { AllItems[i].Display(); } return 0;};
New Item2.h:
class StockItem{public: StockItem(); StockItem(char m_Name[50], short m_InStock, short m_Price, char m_Distributor[100], char m_UPC[35]); void Display(); void Read(ifstream& s);private: short m_InStock; short m_Price; char m_Name[50]; char m_Distributor[100]; char m_UPC[35];};
New errors:
--------------------Configuration: StockItem2 - Win32 Debug--------------------
Compiling...
item2.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\StockItem2\item2.cpp(15) : error C2536: ''StockItem::m_Name'' : cannot specify explicit initializer for arrays
c:\program files\microsoft visual studio\myprojects\stockitem2\item2.h(15) : see declaration of ''m_Name''
C:\Program Files\Microsoft Visual Studio\MyProjects\StockItem2\item2.cpp(15) : error C2536: ''StockItem::m_Distributor'' : cannot specify explicit initializer for arrays
c:\program files\microsoft visual studio\myprojects\stockitem2\item2.h(16) : see declaration of ''m_Distributor''
C:\Program Files\Microsoft Visual Studio\MyProjects\StockItem2\item2.cpp(15) : error C2536: ''StockItem::m_UPC'' : cannot specify explicit initializer for arrays
c:\program files\microsoft visual studio\myprojects\stockitem2\item2.h(17) : see declaration of ''m_UPC''
Error executing cl.exe.
StockItem2.exe - 3 error(s), 0 warning(s)
How in the hell do you get strings of characters in there? ..I''m confused on that.
-J
__________________________________________________________________________________________
Don''t ever frown. You never know when someone is falling in love with your smile.
-J__________________________________________________________________________________________Don't ever frown. You never know when someone is falling in love with your smile.