How do you initialize a static member of a class with return value of some function?



How do you initialize a static member of a class with return value of some function?..

Answer / Kush Gandhi

To initialize a static member of a class with the return value of a function, you can place the initialization inside the class definition itself: nn```c++nclass MyClass {nprivate:nstatic int myStaticMember;npublic:nstatic int getMyStaticMember() {nreturn someFunction();n}nstatic {nmyStaticMember = getMyStaticMember();n}n};nint someFunction() {n// your code heren}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Programming Languages AllOther Interview Questions

I am looking for NIC Sample papers or any patern of questions/ syllabus plz, send me on hamid.khan135@yahoo.in Regard

1 Answers   NIC,


THERE ARE 4 SOURCE FILES WHICH CONTAINS SAME METADATA CREATE A TARGET THAT SHOULD DISPLAY THE FILE NAME ALONG WITH THE RECORD PLEASE SEND THE ANSWERFOR THIS QUESTION WITH MAPPING

1 Answers   Wipro,


1.Describe about your project?

1 Answers  


Expand the following a) ISDN b) CASE c) CSMA/CD d) OOPS e) MIMD

4 Answers   CTS,


what is the diffrence between software and hardware language?

1 Answers  


1. Consider the following code in our example assembly language: ; an example bit of assembly code ROOT: W FATHER FATHER: W SON1 W SON2 SON1: W NIL W NIL ; ---------------------- SON2: W GRANDSON W NIL GRANDSON: W NIL W NIL NIL = 0 Assemble this code carefully following the two pass model, and show the symbol table at the point marked by the dashed line during each pass.

1 Answers   TCS,


What is the difference between CLEAR & RESET and OPEN & CLOSE OPCOEDS(USING RPG/400).wheare we can use this?can any body tell me in real time senario with example please?

1 Answers  


what is difference between c and C#

12 Answers   MCN Solutions,


Write a program which inputs 2 integers representing the sides of a triangle, a and b. Next, write a function which accepts the 2 sides as parameters and returns the hypotenuse of the triangle, c. Use c 2 = a 2 + b 2 To raise a number to an exponent, us e the built - in JavaScript function Math.pow() Let’s say you have a variable x and you want to raise it to the 5 th power, use Math.pow in the following manner... Math.pow( x, 5 ); This will raise x to the 5 th power. To find the square root of a number, use t he built - in JavaScript function Math.sqrt () So to find the square root of x, use Math.pow () in the following manner... Math.sqrt( x ) You must create 2 functions to receive credit for this assignment. Your ‘ main ’ function which is called from the button. And your hypotenuse function. Again, the main function calls upon the hypotenuse f unction when it needs that value. Get the user ’ s input, call the function, output your result. Create your own CSS layout

0 Answers  


1.group by clause explain along with an example 

1 Answers   Parexel,


how many types of operating system are avaliable?

1 Answers   IBM,


1. How many jobs can we write in a single file? 2. How many maximum members can exist in a single partition data set(pds) in jcl?

1 Answers   Steria,


Categories