Concept Clarification

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2009
Posts: 13
Reputation: vddmanikanta is an unknown quantity at this point 
Solved Threads: 0
vddmanikanta vddmanikanta is offline Offline
Newbie Poster

Concept Clarification

 
0
  #1
Apr 24th, 2009
Hai everyone
I need a clarification on the following issue

Why does C++ compiler doesn't allow, to initialize static member function inside a class

And please do tell me about what is meant by initializing a function (member function)

Please help me in getting it clear
thank you

Have a nice day
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 338
Reputation: JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice 
Solved Threads: 61
JasonHippy's Avatar
JasonHippy JasonHippy is offline Offline
Posting Whiz

Re: Concept Clarification

 
0
  #2
Apr 24th, 2009
Originally Posted by vddmanikanta View Post
Hai everyone
I need a clarification on the following issue

Why does C++ compiler doesn't allow, to initialize static member function inside a class

And please do tell me about what is meant by initializing a function (member function)

Please help me in getting it clear
thank you

Have a nice day
I'm not sure I understand what you mean, can you post some example code to show us the problem you're having?

Jas.
Last edited by JasonHippy; Apr 24th, 2009 at 5:48 am. Reason: smelling pistake / typo / got me m***ing fords wuddled
There are 10 types of people in this world.....
Those who understand binary .....
And those who don't!
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 13
Reputation: vddmanikanta is an unknown quantity at this point 
Solved Threads: 0
vddmanikanta vddmanikanta is offline Offline
Newbie Poster

Re: Concept Clarification

 
0
  #3
Apr 24th, 2009
Hai Jasson

Sorry I dont have code
I just want to know the reason why they have designed language this way.

That gives me fair amount of idea of why and where exactly can I use "static ".
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 794
Reputation: siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of 
Solved Threads: 135
siddhant3s's Avatar
siddhant3s siddhant3s is offline Offline
Master Poster

Re: Concept Clarification

 
0
  #4
Apr 24th, 2009
>>initialize static member function
>>initializing a function

These two things doesn't mean anything in C++. You don't initialize a function. You initialize an object ( or a variable, whatever you call them).
Things you can do with functions are:
Declare them
Define them
Call them
Overload them
Templatize them
May be more but I just cannot think of them right now.

There is no thing as initializing a function (or member function)
Siddhant Sanyam
(Not posting much)
My Blog: Yatantrika
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,936
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 305
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: Concept Clarification

 
0
  #5
Apr 24th, 2009
Did you read this already?
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 338
Reputation: JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice JasonHippy is just really nice 
Solved Threads: 61
JasonHippy's Avatar
JasonHippy JasonHippy is offline Offline
Posting Whiz

Re: Concept Clarification

 
0
  #6
Apr 24th, 2009
Originally Posted by siddhant3s View Post
>>initialize static member function
>>initializing a function

These two things doesn't mean anything in C++. You don't initialize a function. You initialize an object ( or a variable, whatever you call them).
Things you can do with functions are:
Declare them
Define them
Call them
Overload them
Templatize them
May be more but I just cannot think of them right now.

There is no thing as initializing a function (or member function)
To follow on from this reply if I may, and the original question:

Typically you'd usually use a public static member function as an external interface to your class...
In other words, they can be called from outside of the class and also without there necessarily being an active instance of the class!

For example if you had a singleton object, you'd usually include a public static member function in it's class definition to return a pointer to the one and only instance of the object (which could be stored in the class as a private static object, or as a static object in the class's namespace).

That way if other external classes/objects need to be able to access/use your singleton, they have a means to access it.

Offhand I can't think of any practical examples for protected/private static functions...But I'm sure some of the more experienced programmers on here can expand on this!

Cheers for now,
Jas.
There are 10 types of people in this world.....
Those who understand binary .....
And those who don't!
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 13
Reputation: vddmanikanta is an unknown quantity at this point 
Solved Threads: 0
vddmanikanta vddmanikanta is offline Offline
Newbie Poster

Re: Concept Clarification

 
0
  #7
Apr 24th, 2009
Thanks Jason
I got it.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC