Explain member functions of a class, C/C++ Programming

Assignment Help:

Member Functions of a Class

A member function of the class is similar as an ordinary function. Its declaration in a class template must explain its return value as well as the list of its arguments. You can declare or explain the function in the class specifier itself, in which case it is just like a normal function. But since the functions within the class specifier is considered inline by the compiler we should not explain large functions and functions with control structures, iterative statements etc should not be written inside the class specifier. Though, the definition of a member function differs from that of an ordinary function if written outside the class specifier. The header of a member function uses the scope operator (::) to state the class to which it belongs. The syntax is:

return_type  class_name :: function_name (parameter list)       

             {

                :

                }

 

e.g.

                void player :: getstats (void)

                 {

                                :

                 }

                void player :: showstats (void)

                 {

                                :

                                :

                 }

This notation shows that the functions getstats () and showstats() belong to the class player.

 


Related Discussions:- Explain member functions of a class

What is the best fit algorithm, The Best fit algorithm: The best fit metho...

The Best fit algorithm: The best fit method occurs the smallest free block whose size is greater than or equivalent to n. An algorithm to get such a block by traversing the whole

Flow chart, how made a flow chart of prime number by using for loop

how made a flow chart of prime number by using for loop

Thermodynamics, the program that solve the efficiency of otto cycle

the program that solve the efficiency of otto cycle

Program for implement vectors and iterators, - Write a program using vector...

- Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles. The user should be able to view all DVD titles in his library, add and d

Sentinel controlled loop, develop an algorithm using pseudocode for computi...

develop an algorithm using pseudocode for computing cos(x) and sin(x). use a sentinel controlled while loop. use the series definition of e^+-jx

Client server using c, (a) client server or multithreaded client-server, wh...

(a) client server or multithreaded client-server, where server will create pool of worker threads (say 5) to provide services to pool of clients (say 5 ).Server should be behaving

C program for find even & odd no.s in the array , C Program for FIND EVEN &...

C Program for FIND EVEN & ODD NO.S IN THE ARRAY #include stdio.h> #include string.h> #include conio.h> void main() {           int i=0,j=0, l_e[100],l_o[100];

Bus Connection, how to explain working of bus connection

how to explain working of bus connection

Program, write a program for convert numbers upto 9 to alphabet?Eg.now ente...

write a program for convert numbers upto 9 to alphabet?Eg.now enter the inputis 666 means output is "0" lphabet

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd