Hi, I am doing my first classes work (C++) and I've come up with this:
Code:
#include <iostream>
#include <string>
#include "item1.h"
using namespace std;
StockItem::StockItem()
: m_Name(), m_InStock(0), m_Price(0), m_Distributor(), m_UPC()
{
}
StockItem::StockItem(string Name, short InStock,
short Price, string Distributor, string UPC)
: m_Name(Name), m_InStock(InStock), m_Price(Price),
m_Distributor(Distributor), m_UPC(UPC)
{
}
void StockItem::Display()
{
cout << "Name: ";
cout << m_Name << endl;
cout << "Number in stock: ";
cout << m_InStock << endl;
cout << "Price: ";
cout << m_Price << endl;
cout << "Distributor: ";
cout << m_Distributor << endl;
cout << "UPC: ";
cout << m_UPC << endl;
}
and saved it here:
C:\Documents and Settings\Chris\My Documents\My game\Lobsters\classes\item1.cpp
And saved this:
Code:
class StockItem
{
public:
StockItem();
StockItem(std::string Name, short InStock, short Price,
std::string Distributor, std::string UPC);
void Display();
private:
short m_InStock;
short m_Price;
std::string m_Name;
std::string m_Distributor;
std::string m_UPC;
};
here:
C:\Documents and Settings\Chris\My Documents\My game\Lobsters\classes\item1.h
But it comes with these errors
3 C:\Documents and Settings\Chris\My Documents\My game\Lobsters\classes\item1.cpp In file included from C:/Documents and Settings/Chris/My Documents/My game/Lobsters/classes/item1.cpp
[Linker error] undefined reference to `WinMain@16'
What's wrong, I'm using Dev c++ by the way.
Thanks