Members BookmarksPolls Fresher Jobs Funny Pictures MCA Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

Advertisements


website counter



function member definition in c++


Posted Date: 30 Apr 2008    Resource Type: Articles/Knowledge Sharing    Category: Education

Posted By: mohit       Member Level: Gold
Rating:     Points: 4



Function member definition


If a function member is not defined as inline, then it must be defined outside the class. This done by prefixing the function name with the class name and the scope-resolution operator, :: (colon-colon). This qualifies the name to avoid ambiguity when function names are reused in different classes. This appears to break the rules of scope, because references to variables declared within the scope of the class are allowed in function member definitions. The rules are merely being extended, however, if it is accepted that the definition of the function is "really" contained in the class, but is just placed externally for readability purposes. It also provides a declaration versus implementation view that abstract data typing demands. An exmple of external definition is:


class Ext {
private:
int privateVariable;
public:
void extFun();
...
};


void Ext::extFun() {
privateVariable = 10; // reference to name in the class scope
}






Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: ENCAPSULATIO IN C++
Previous Resource: function scope in c++
Return to Discussion Resource Index
Post New Resource
Category: Education


Post resources and earn money!
 
Related Resources


Contact Us    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.