WAP in c++ a class name item that contain 2 variable and cost in pvt sec & put and create a obj in main print no. Of cost | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

WAP in c++ a class name item that contain 2 variable and cost in pvt sec & put and create a obj in main print no. Of cost

#include <iostream> using namespace std; void getdata(int a,float b); void putdata(); class item { public : int mobile,laptop; private : mobile = a; laptop =b; }; void item::getdata(int a,float b) { num=a; cost=b; } void item::putdata () { cout<<"number"<<num<<endl <<"cost"<<cost<<endl; } int main() { obj m; object.item= putdata(); object.item=getdata(int a,float b); return 0; } Guys pls help to find out the error I need this in college assignments

18th Jun 2021, 3:20 AM
Kartik Yadav
Kartik Yadav - avatar
1 Answer
+ 1
What are you doing I don't know because you have declared get data ,put data function outside of the class item but you are implementing them using item scope resolution operator I am not understanding why you have done this .now in main you have written object.item= functions i think which makes no sense, what do you mean by this I don't know I think ur code is totally wrong, U should have to write it again
18th Jun 2021, 4:50 AM
saurabh
saurabh - avatar