|
楼主 |
发表于 2005-3-5 09:48:05
|
显示全部楼层
//itemtst1.cpp
#include <iostream>
#include <string>
#include "item1.h"
using namespace std;
int main()
{
StockItem soup;
soup = StockItem("Chunky Chicken",32,129,
"Bob's Distribution","123456789");
soup.Display();
return 0;
}
//item1.h
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;
};
//item1.cpp
#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;
}
D:\test>bcc32 itemtst1
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
itemtst1.cpp:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external 'StockItem::StockItem()' referenced from D:\TEST\ITEM
TST1.OBJ
Error: Unresolved external 'StockItem::StockItem(std::basic_string<char, std::ch
ar_traits<char>, std::allocator<char> >, short, short, std::basic_string<char, s
td::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char
_traits<char>, std::allocator<char> >)' referenced from D:\TEST\ITEMTST1.OBJ
Error: Unresolved external 'StockItem::Display()' referenced from D:\TEST\ITEMTS
T1.OBJ
D:\test>bcc32 item1
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
ITEM1.cpp:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_main' referenced from C:\BORLAND\BCC55\LIB\C0X32.OB
J |
|