473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Why can this not be initialized?

fl
Hi,
The following cannot be initilized. The error is LNK2001.

Bulk_item("345", 45, 3, .15);

bsk2 error LNK2001: symbole externe non r¨¦solu "public: virtual
double __thiscall Bulk_item::net_price(unsigned int)const " (?
net_price@Bulk_item@@UBENI@Z)

I don't know the reason. Could you tell me the problem? Thanks.

----------------------------
class Bulk_item : public Item_base {
public:
std::pair<size_t, doublediscount_policy() const
{ return std::make_pair(min_qty, discount); }
// other members as before
Bulk_item* clone() const
{ return new Bulk_item(*this); }
Bulk_item(): min_qty(0), discount(0.0) { }
Bulk_item(const std::string& book, double sales_price,
std::size_t qty = 0, double disc_rate = 0.0):
Item_base(book, sales_price),
min_qty(qty), discount(disc_rate) { }

// redefines base version so as to implement bulk purchase
discount policy
double net_price(std::size_t) const;
private:
std::size_t min_qty; // minimum purchase for discount to apply
double discount; // fractional discount to apply
};
------------
Jan 2 '08 #1
7 1669
On Jan 2, 8:29*am, fl <rxjw...@gmail.comwrote:
Hi,
The following cannot be initilized. The error is LNK2001.

Bulk_item("345", 45, 3, .15);

bsk2 error LNK2001: symbole externe non r¨¦solu "public: virtual
double __thiscall Bulk_item::net_price(unsigned int)const " (?
net_price@Bulk_item@@UBENI@Z)

I don't know the reason. Could you tell me the problem? Thanks.

----------------------------
class Bulk_item : public Item_base {
public:
* * std::pair<size_t, doublediscount_policy() const
* * * * { return std::make_pair(min_qty, discount); }
* * // other members as before
* * Bulk_item* clone() const
* * * * { return new Bulk_item(*this); }
* * Bulk_item(): min_qty(0), discount(0.0) { }
* * Bulk_item(const std::string& book, double sales_price,
* * * * * * * std::size_t qty = 0, double disc_rate = 0.0):
* * * * * * * * *Item_base(book, sales_price),
* * * * * * * * *min_qty(qty), discount(disc_rate) { }

* * // redefines base version so as to implement bulk purchase
discount policy
* * double net_price(std::size_t) const;
private:
* * std::size_t min_qty; * // minimum purchase for discount to apply
* * double discount; * * * // fractional discount to apply};
You haven't shown enough code to understand what the reason could be
(the error message is also in a different language that I don't
understand) but the most probable reason would be a lacking definition
for member function net_price. The error message does not say anything
about the initialization being problematic.
Jan 2 '08 #2
On Jan 1, 10:29 pm, fl <rxjw...@gmail.comwrote:
Hi,
The following cannot be initilized. The error is LNK2001.

Bulk_item("345", 45, 3, .15);

bsk2 error LNK2001: symbole externe non r¨¦solu "public: virtual
double __thiscall Bulk_item::net_price(unsigned int)const " (?
net_price@Bulk_item@@UBENI@Z)

I don't know the reason. Could you tell me the problem? Thanks.

----------------------------
class Bulk_item : public Item_base {
public:
std::pair<size_t, doublediscount_policy() const
{ return std::make_pair(min_qty, discount); }
// other members as before
Bulk_item* clone() const
{ return new Bulk_item(*this); }
Bulk_item(): min_qty(0), discount(0.0) { }
Bulk_item(const std::string& book, double sales_price,
std::size_t qty = 0, double disc_rate = 0.0):
Item_base(book, sales_price),
min_qty(qty), discount(disc_rate) { }

// redefines base version so as to implement bulk purchase
discount policy
double net_price(std::size_t) const;
Where is the implementation of the above virtual member function?
The compiler says it can't resolve it.

The error given by compiler is quite clear.
private:
std::size_t min_qty; // minimum purchase for discount to apply
double discount; // fractional discount to apply};

------------
Jan 2 '08 #3
On Jan 2, 9:44 am, Salt_Peter <pj_h...@yahoo.comwrote:
On Jan 1, 10:29 pm, fl <rxjw...@gmail.comwrote:
Hi,
The following cannot be initilized. The error is LNK2001.
Bulk_item("345", 45, 3, .15);
bsk2 error LNK2001: symbole externe non r¨¦solu "public: virtual
double __thiscall Bulk_item::net_price(unsigned int)const " (?
net_price@Bulk_item@@UBENI@Z)
I don't know the reason. Could you tell me the problem? Thanks.
----------------------------
class Bulk_item : public Item_base {
public:
std::pair<size_t, doublediscount_policy() const
{ return std::make_pair(min_qty, discount); }
// other members as before
Bulk_item* clone() const
{ return new Bulk_item(*this); }
Bulk_item(): min_qty(0), discount(0.0) { }
Bulk_item(const std::string& book, double sales_price,
std::size_t qty = 0, double disc_rate = 0.0):
Item_base(book, sales_price),
min_qty(qty), discount(disc_rate) { }
// redefines base version so as to implement bulk purchase
discount policy
double net_price(std::size_t) const;

Where is the implementation of the above virtual member function?
The compiler says it can't resolve it.

The error given by compiler is quite clear.
private:
std::size_t min_qty; // minimum purchase for discount to apply
double discount; // fractional discount to apply};
------------
Isn't that reported by the linker?
Jan 2 '08 #4
On Jan 2, 12:16 am, Rahul <sam_...@yahoo.co.inwrote:
On Jan 2, 9:44 am, Salt_Peter <pj_h...@yahoo.comwrote:
On Jan 1, 10:29 pm, fl <rxjw...@gmail.comwrote:
Hi,
The following cannot be initilized. The error is LNK2001.
Bulk_item("345", 45, 3, .15);
bsk2 error LNK2001: symbole externe non r¨¦solu "public: virtual
double __thiscall Bulk_item::net_price(unsigned int)const " (?
net_price@Bulk_item@@UBENI@Z)
I don't know the reason. Could you tell me the problem? Thanks.
----------------------------
class Bulk_item : public Item_base {
public:
std::pair<size_t, doublediscount_policy() const
{ return std::make_pair(min_qty, discount); }
// other members as before
Bulk_item* clone() const
{ return new Bulk_item(*this); }
Bulk_item(): min_qty(0), discount(0.0) { }
Bulk_item(const std::string& book, double sales_price,
std::size_t qty = 0, double disc_rate = 0.0):
Item_base(book, sales_price),
min_qty(qty), discount(disc_rate) { }
// redefines base version so as to implement bulk purchase
discount policy
double net_price(std::size_t) const;
Where is the implementation of the above virtual member function?
The compiler says it can't resolve it.
The error given by compiler is quite clear.
private:
std::size_t min_qty; // minimum purchase for discount to apply
double discount; // fractional discount to apply};
------------

Isn't that reported by the linker?
yes it is
Jan 2 '08 #5
fl
On 1 jan, 23:44, Salt_Peter <pj_h...@yahoo.comwrote:
On Jan 1, 10:29 pm, fl <rxjw...@gmail.comwrote:


Hi,
The following cannot be initilized. The error is LNK2001.
Bulk_item("345", 45, 3, .15);
bsk2 error LNK2001: symbole externe non r¨¦solu "public: virtual
double __thiscall Bulk_item::net_price(unsigned int)const " (?
net_price@Bulk_item@@UBENI@Z)
I don't know the reason. Could you tell me the problem? Thanks.
----------------------------
class Bulk_item : public Item_base {
public:
* * std::pair<size_t, doublediscount_policy() const
* * * * { return std::make_pair(min_qty, discount); }
* * // other members as before
* * Bulk_item* clone() const
* * * * { return new Bulk_item(*this); }
* * Bulk_item(): min_qty(0), discount(0.0) { }
* * Bulk_item(const std::string& book, double sales_price,
* * * * * * * std::size_t qty = 0, double disc_rate = 0.0):
* * * * * * * * *Item_base(book, sales_price),
* * * * * * * * *min_qty(qty), discount(disc_rate) { }
* * // redefines base version so as to implement bulk purchase
discount policy
* * double net_price(std::size_t) const;

Where is the implementation of the above virtual member function?
The compiler says it can't resolve it.

The error given by compiler is quite clear.
private:
* * std::size_t min_qty; * // minimum purchase for discount to apply
* * double discount; * * * // fractional discount to apply};
------------- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -
They are examples for C++ primer 4th. director 15\Basket_main.cpp.
Don't know why they have problems.

http://www.informit.com/store/produc...721481&redir=1
Jan 2 '08 #6
fl
On 1 jan, 23:44, Salt_Peter <pj_h...@yahoo.comwrote:
On Jan 1, 10:29 pm, fl <rxjw...@gmail.comwrote:


Hi,
The following cannot be initilized. The error is LNK2001.
Bulk_item("345", 45, 3, .15);
bsk2 error LNK2001: symbole externe non r¨¦solu "public: virtual
double __thiscall Bulk_item::net_price(unsigned int)const " (?
net_price@Bulk_item@@UBENI@Z)
I don't know the reason. Could you tell me the problem? Thanks.
----------------------------
class Bulk_item : public Item_base {
public:
* * std::pair<size_t, doublediscount_policy() const
* * * * { return std::make_pair(min_qty, discount); }
* * // other members as before
* * Bulk_item* clone() const
* * * * { return new Bulk_item(*this); }
* * Bulk_item(): min_qty(0), discount(0.0) { }
* * Bulk_item(const std::string& book, double sales_price,
* * * * * * * std::size_t qty = 0, double disc_rate = 0.0):
* * * * * * * * *Item_base(book, sales_price),
* * * * * * * * *min_qty(qty), discount(disc_rate) { }
* * // redefines base version so as to implement bulk purchase
discount policy
* * double net_price(std::size_t) const;

Where is the implementation of the above virtual member function?
The compiler says it can't resolve it.

The error given by compiler is quite clear.
private:
* * std::size_t min_qty; * // minimum purchase for discount to apply
* * double discount; * * * // fractional discount to apply};
------------- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -
OK now. One has to define the following function:
virtual double net_price(std::size_t) const
void display(std::ostream&) const

Thanks to all.
Jan 2 '08 #7
fl
On 1 jan, 23:44, Salt_Peter <pj_h...@yahoo.comwrote:
On Jan 1, 10:29 pm, fl <rxjw...@gmail.comwrote:


Hi,
The following cannot be initilized. The error is LNK2001.
Bulk_item("345", 45, 3, .15);
bsk2 error LNK2001: symbole externe non r¨¦solu "public: virtual
double __thiscall Bulk_item::net_price(unsigned int)const " (?
net_price@Bulk_item@@UBENI@Z)
I don't know the reason. Could you tell me the problem? Thanks.
----------------------------
class Bulk_item : public Item_base {
public:
* * std::pair<size_t, doublediscount_policy() const
* * * * { return std::make_pair(min_qty, discount); }
* * // other members as before
* * Bulk_item* clone() const
* * * * { return new Bulk_item(*this); }
* * Bulk_item(): min_qty(0), discount(0.0) { }
* * Bulk_item(const std::string& book, double sales_price,
* * * * * * * std::size_t qty = 0, double disc_rate = 0.0):
* * * * * * * * *Item_base(book, sales_price),
* * * * * * * * *min_qty(qty), discount(disc_rate) { }
* * // redefines base version so as to implement bulk purchase
discount policy
* * double net_price(std::size_t) const;

Where is the implementation of the above virtual member function?
The compiler says it can't resolve it.

The error given by compiler is quite clear.
private:
* * std::size_t min_qty; * // minimum purchase for discount to apply
* * double discount; * * * // fractional discount to apply};
------------- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -
Hi,
Yes, I have to define the routine. But for the following, I don't know
how to define it. Could you explain how to deal with ostream&? Give me
an example please. Thanks.

void display(std::ostream&) const;
Jan 2 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Gary | last post by:
Exception in thread "main" java.lang.NullPointerException at Bookstore.openInputStream(Bookstore.java:80) at Bookstore.main(Bookstore.java:55) Any Ideas?
1
by: TPSreport | last post by:
I log on to the cookieless application, work within it for awhile, jump to a URL outside the application, then return to the application. As soon as a db call is required, I get the error below. ...
22
by: Chris Schumacher | last post by:
I wrote the following program to demonstrate an oddity I found in C++. #include <iostream> using namespace std; int main() {int *p, *q; p = q; q = new int;
10
by: Wat | last post by:
Is char a = ""; the same as, char a; a = '\0'; ?
3
by: lauch2 | last post by:
Can anyone talk me is there existed a "default" value for a un-initialized int variable in a release build in VC6 and VC7.1. (I know there is a compilation warning) For Example: main(){ int a;...
62
by: Snis Pilbor | last post by:
Hi, It seems pretty common to return pointers to a static array, for example: char *capitalize( char *name ) { static char buf; sprintf( buf, "%s", name );
15
by: thinktwice | last post by:
char a = { 0 } is it ok?
4
by: Nishu | last post by:
Hi All, What is the C-standard expected result for referring the 'uninitialized element' of the partial initialized automatic array ? /*************************/ #include <stdio.h> int...
5
by: campyhapper | last post by:
I've seen this in C++, not Objective C: namespace bar { struct foo { foo (int a, int b) : int a_, int b_ {} }; }
24
by: DomoChan | last post by:
the code below will compile in visual c++ 2003, but im not sure its valid. unsigned char myString = ""; after this line executes, all the bytes within myString are indeed set to '0's' but is...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.