hey guys i m a free lancer in web designing n i 've a ques. Can smbdy chk out my code: | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

hey guys i m a free lancer in web designing n i 've a ques. Can smbdy chk out my code:

#inlcude<iostream> #inlcude<string> #inlcude<ctype> #inlcude<stdlib> #inlcude<stdio> using namespace std; class account{ private: char name_private; int age_private; int rollno_private; public: void func(char name_pub[], int age_pub, int rollno_pub){ name_private = name_pub; age_private = age_pub; rollno_private = rollno_pub; } int getName(){ return(name_private); } int getAge(){ return(age_private); } int getRollno(){ return(rollno_private); } }; void main(){ char name[] = "Harsh"; int age = 16; int rollno = 7; account obj; obj.func(name, age, rollno); cout<<"Name is: "<<getName(); cout<<"Age is: "<<getAge(); cout<<"Rollno is: "<<getRollno(); } //will it output:: Harsh 16 7

12th Jun 2016, 7:20 AM
Harshveer
Harshveer - avatar
4 Answers
0
What do you expect your code to do? What is the question? As far a I can tell, in your last 3 line of code you are not calling the obj's getName, getAge and getRollno. You should have obj.getName(), obj.getAge() and obj.getRollno().
12th Jun 2016, 3:16 PM
Andrei Timofte
Andrei Timofte - avatar
0
o thanks a lot;; actually i gt it ryt already
12th Jun 2016, 3:19 PM
Harshveer
Harshveer - avatar
0
ty fr ur effrts
12th Jun 2016, 3:20 PM
Harshveer
Harshveer - avatar
0
Actually there a few compilation errors in this program!
13th Jun 2016, 6:45 AM
Vamshi Krishna
Vamshi Krishna - avatar