Hi there,
some explanation to your questions:
nAd wrote: |
---|
but i am using this statement for name as an input
char name;
but you wrote std::string name;
what is the difference in these two statements?
i did not study std::string in lectures |
Char reserves space in the memory for just one character.
If you want to store more characters, the easiest way is to use a string.
Strings are objects that allow you to manipulate series of chars in a clean and easy way. For more info see http://www.cplusplus.com/reference/string/string/ .
Note that in order to use them you need to do
#include <string>
at the top of your program.
nAd wrote: |
---|
which header file will manipulate this data type?
<iostream.h> |
I'm not sure what you meant by that, if you meant what header file you need to use string, that's
#include <string>
nAd wrote: |
---|
writing the friend function and its working |
Friend functions are functions which are allowed to access a class's private data, whilst not being a member of the class.
For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
class Person {
private:
//this variable is private and thus only accessible normally within the object
int phonenumber;
public:
friend void telephone(Person);
Person(int phone) { phonenumber = phone; }
};
//note how we don't say Person::telephone, this is not a member of the Person class
void telephone(Person recipient)
{
dial(recipient.phonenumber);
}
int main()
{
//make a person wth telephonenumber
Person mark(7777444);
//telephone the person, because "telephone()" is a friend function,
//it can access the "phonenumber" private property.
telephone(mark);
}
|
So in your case, the friend function will take a "Customer" as an argument, allowing you to access his "spent amount". Then, you will have to check
if that amount is higher than 5000, higher than 5000
and smaller than 10000, or
else higher than 10000. Depending on that, you set the amount of tax and discount and you return the calculated result from the function.
nAd wrote: |
---|
secondly the display function, because the main thing is the display function i think |
Let's come back to that when everything else works.
Hope that helps.
Salaum Aleikum (I think that's how you write it?)
NwN