the program is to print a bill using two classes-customer and item.... in class customer, members are itemname and customer name.in item, members are itemname itemcode,itemprice,noof items...and functions to calculate bill and update stock.
iam in confusion with the logic.....i think that it can be done by using nested class???

Edited 4 Years Ago by deceptikon: Moved to C++

It will be best if you do separate classes and then apply inheritance in your classes.
Post your code.

i think that it can be done by using nested class???

.

... and then apply inheritance in your classes.

No to both; you've already been told which classes to write, and there is no inheritance relationship involved:

the program is to print a bill using two classes-customer and item

You also know what the data fields should be:

class customer, members are itemname and customer name.in item, members are itemname itemcode,itemprice,noof items

...and what support functions to write:

and functions to calculate bill and update stock

The basic structure has been laid out for you pretty clearly.

Post your code.

Yes to this!

If you've already tried to write something, post it and we'll do our best to point you in the right direction. If you're having trouble with it, read about how to write classes, try to write them yourself, and post what you come up with.

I agree. Try and build the classes. You practically have the layout you need. Then post your code here if you need extra help... but we wont code this for you and post it here, you should try and make an effort to come up with the solution and then we help out as much as we can. Good Luck!

and then apply inheritance in your classes.
No to both; you've already been told which classes to write, and there is no inheritance relationship involved:

Shouldn't some relationship be here though? Ok, so inheritence can have a "Is a"/"Can Be" relationship so obviously "Customer" {is a} "Item" wouldn't work, however, association could be used, surly? Customer {can have} "Item" relationship would, IMO anyway.. I might be wrong!

Edited 4 Years Ago by phorce

Ok, so inheritence can have a "Is a"/"Can Be" relationship so obviously "Customer" {is a} "Item" wouldn't work

Right, that's what an inheritance relationship would mean.

however, association could be used, surly? Customer {can have} "Item" relationship would, IMO anyway..

That's certainly a possibility. But that isn't an inheritance relationship, which is what I was talking about. What you're describing is more of an ownership property, e.g., Customer has some sort of collection property to contain Items.

Shouldn't some relationship be here though?

Yes, there should... and this is where I'll guess that we're looking at an incomplete assignment. The whole customer/order idea is pretty common when teaching object-oriented concepts, but usually you have something like a class called "Order" that takes care of relating Customers to Items.

This article has been dead for over six months. Start a new discussion instead.