Member Function with Arguments | C ++ Tutorial | Mr. Kishore

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi welcome to nourish ID this is Keisha and today we are going to continue the class concept that is how to send the argument on how to review the written values from member functions today I am going to explain how to pass the argument to the member functions on how to return the values from member functions okay now as usual function contains arguments or parameters and function also having a written word like the normal member functions we can also send the arguments to member functions and we can also receive the values from member functions the values we are sending to the function or called arguments or the function which is giving the values are called written values now I am going to explain with one example how to send and SQ the values to or from a function as usual regular header files i was kim dot h for input and output operations corner dot H for clean clear and get the edge functions next I am going to give class Here I am going to start a class here now class for example employee now the class name is employee now similarly employees having some data for example I am going to take int employee ID next character employee may next float salary now these are the three members in this example first of all I am going to give you only the argument in next example we are going to discuss how to receive the return value now how to pass the arguments to the function next employee ID is the employee name is their salary they actually we are called what data members next to work with to the private data members we should have to write a number functions within the same that's why in publicly real world get TMP next actually here my intention is what I want the friend of the argument that's why here in brackets I am going to use the argument list first argument is what employee ID is integer that's why I ent I'll D next character here washeteria name employing in place of that I am going to use name and I want to change the word salary now route that I wrote for example basic next is semicolon because of I want to conduct the definition outside next another member function void with EMP now there is no argument brackets close amigos that means class definition completed now the class name is employee and the members are already named salary and member functions are getting Embree put the MP next now we have two different the member function outside of the class when the number function definition is outside of the class there is a rule without discussion that is scope operator should be usual that's why I have to return right here return type is void now of two oiled next number functioning get tmb that's why I get EMV next how many arguments will have to face three arguments one is integer on a string ponies float that's why faster ing I'll D next care name of kanji uh throat basic now how many arguments three arguments now we have to pass these arguments in formal parameter values to the numbers that is why here I D equal to see this here ID is argument I want to send this are going to employ a here employee ID equal to ID now what happened I did having some value know that value is storing DMV ID next name for example I am going to write name equal to means employee name the file employee name equal to name now if you see error because of in C and C++ we are facing one problem direct stringer copying not alone C compiler and C++ compiler never supports directive single copying that means this string is never copied into this string using equal operator okay that's why they have provided one predefined function called strcpy that's why just you how to use the IP or c py like this str c py off destination first means where we want to store the string where we want to store here in any name we want to store listing that's why you name comma next so see what this name that's why it is the source and it is the destination that's right here shows me how to write me now what happens this mean copy into e name okay and here it is a predefined function available in sting or H that's why we have to add sting dot H also here fr here hash include string you got hitch also added because of STR CPU Lex third argument is what basic self that's well shall equal to basic and actually basically the floating did that's why we can assign directly to the variable by using equal operator now brackets close that's why here get EMP is a member function which is having a argument on these arguments are stored inside ID means employee employee and salary his complete next course is what we have to print to this day Donna that's why there is another function how usual put TM now we have to go for put to definition now Lloyd put TM but here the problem is also that we are getting definitions now now here the definitions are conducted where inside the class or outside the class outside of the class well this index is used what happens it gives here and because of the compiler does not know yet EMP is what that's why the rule is what here first why it later EMP : : now your compiler understand get EMP is the member of EMP class now there is no problem okay otherwise we are going to get error same to same here also between these the number of same EMP class as a wise EMP class name : : put p.m. PE now there is no argument that's why empty brackets letter input EMP I want to show the results the verse means what employee ID employment self that's why see out of to employ LD equal to EMP ID and candle for next line next see out name equal to means employee name equal to X a name an end L next C out salary equal to hell access function completed that's why here it is a get EMP definition it is the Pro Tem bit affection now definitions also complete here what they are declaration function declarations now it is what definition now one more topic - no that is function called where we have to call the function from main function that's why now I am going to start function love main function okay fine another many started first of all to invoke the member functions we should have to declare the object of the class law that's why it's faster EMP e now is no object now object and memory created okay later we have to call the functions now first I'm going to use clean clear later ee dot get EMV under get EMP is having arguments no that's why we have to change the values for example here 1 0 1 next name issue for example salary 10,000 now what happened one not one possible to ID and key sure positive name and 10,000 positive basic now that idea is positive employee ID and sure is positive employee name and 10,000 is going to salary that's why all the members are initialize it now initialization passing of the values complete later next step is what we have to prove the result means output function is what put EMV that's why e dot put EMV know there is Nordmann before empty bracket when e dot put PMP is called what happens compilation jumper to the definition passed means this one now field Yogi's was printing first employ LD brain get employed is what 1 0 1 and we'll use what next line in excellent employing it sure is printed in excellent salary 10,000 is printed now the program cost for input process completed output process completed means total program conveyed enough that's why we have to close the problem now to get the answer directly where is he get CH and when the program is completed should have to close the main function the five main also closer now it is how to send the argument to the number functions okay it is how the arguments to the number functions and how to enter the values okay thank you [Music]
Info
Channel: Naresh i Technologies
Views: 44,120
Rating: undefined out of 5
Keywords: Member Function with Arguments, Member Function, Arguments, c++, c (programming language), C ++ Tutorial, C++ Training, Kishore, Nareshit
Id: LGGm8hqn9Z4
Channel Id: undefined
Length: 11min 40sec (700 seconds)
Published: Mon Mar 27 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.