Error in - classes

Hello.
The question was asking for.

(i) Create a class called Purchase.
(ii) Data member (set to private) : name(string), qty(int), price(float) and total(float).
Public member function : Define the member functions outside of the class.
(a) set_data(…)
Take in 3 parameters of type string, int and float, and
set the parameters to name, qty and price.
(b) calculate()
Calculate the total amount of payment to be made.
(c) print()
Display all the information on screen.
(iii) In main() function, create an object of class Purchase called p.
(iv) In main() function get input from the user and pass the data to method set_data(...) so that the values can be set to the appropriate variables.
(v) In main() function call function calculate() to calculate the total amount to be paid by a customer.
(vi) In main() function call function print() to display all the information as shown below.



So far I have done

#include<iostream>
#include<string>
using namespace std;

class Purchase{
private:
string name;
int qty;
float price;
float total;

public:
void set_data(string name,int qty,float price);

{
cout<<"========================"<<endl;
cout<<" WELCOME "<<endl;
cout<<"========================"<<endli;
cin.ignore();
cout<<"\rEnter name : \t";
getline (cin,name);

cin.ignore();
cout<<"Enter quantity : \t";
getline(cin quantity);

cin.ignore();
cout<<"Enter price : \t";
cin>>price;

}


Now I am not sure whether I do it right or not.
Please guide me on this chapter classes . Thank you
your set_data function should be like this.

1
2
3
4
5
6
7
void set_data(string name1,int qty1,float price1)
{

name=name1;
qty=qty1;
price=price1;
}
Thank you .I have tried and I got error on the below of it.
I dnt know what when wrong again
Topic archived. No new replies allowed.