Doubts regarding class and object

I know the functions are loaded only once in the memory. My doubt is... if we create an object of a class how it refer the function? What is the thing behind the object creation and function calling? Is there any pointer in the object to the function?

Answers


I believe you're looking for the term "virtual method table".

This is the mechanism that languages (compilers) use to determine what method to actually invoke when a call to a virtual function is made (and in Java all functions are virtual).


When you create an object, only it's data fields are being created (allocated). Class methods forever resides in memory during whole program run.

Does object have pointer to the method or no is language-dependent. For example, in C++ object are containing pointers to virtual methods, while normal and static methods are called just by their constant addresses.


Need Your Help

How to create a level with curved lines with cocos2d + Box2d on the iphone?

iphone cocos2d-iphone box2d collision curve

I'd like to create a game that has levels such as this: http://img169.imageshack.us/img169/7294/picdq.png

Return true or false from laravel to Angularjs $scope

javascript php angularjs laravel

I'm trying to return true or false from Laravel to a $scope directive in Angularjs. This is the laravel code that is called:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.