I need help for my homework C++

Discussion in 'Mac Programming' started by onqun, Jun 28, 2008.

  1. onqun macrumors member

    Oct 13, 2006
    Hello guys, i need to submit a homework Wednesday. the question is write a paragraph for each of the following topics.
    2.friend functions
    3.static class member
    4. static member
    This homework is really important so i just want to be ensure about my answers if the answers are enough or i need to add something. if someone helps i would be really happy thanks a lot.
    here is my answers,

    Composition, which has objects from other classes as members. They do not do something by themselves,so we need to combine them thats why it is called composition. For example, light bulb means nothing by itself, but when you combine it to the electricity and to a lamp it makes a lamp or a leaf, branch and root doesn’t make any sense ,but when hey come together they make a flower. So we try to make flower and working lamp, our main theme for composition. If we don’t have flower and lamp others would be useless.

    Friend Function
    Friend function, we define a class outside of another class. Thus, we can access the data in that class. We declare a data as private inside a class and which is not accessible from outside class. A function which is not a member or an external of a can can never access a private data. But sometimes we need to access the private data so in order to that we make them friend. So it can access the data of other class. Friend Functions can increase the performance.

    Static Class Member
    Static Class Member, each object of a class has its own copy of all the data members of the class. Some cases, only one copy of a variable should be shared by all objects of a class for these cases we use static member. When we declare an object of a class having a static member, static member is not part of the class object. They all have class scope moreover, they can declared as public private or protected. They initialized with 0 and only once. It usually used for recording data common to all objets of a class.

    Static Variable
    Even when a function does not operate, such as when it needs to find a value for each given input,the static local variables may be used in such cases. Static local variable, does not appear until the first input is given to the function including them. Thereafter it subsists until the end of the consisting program.

Share This Page