BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan Right Header

HOME BZU Mail Box Online Games Radio and TV Cricket All Albums
Go Back   BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan > Institute of Computing > Bachelor of Science in Information Technology > BsIT 3rd Semester > Object Oriented Programming

Object Oriented Programming By Mam Sidra Malik


 
 
Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 14-10-2008, 02:05 AM
BSIT07-01's Avatar
Addicted to Computer


 
Join Date: Sep 2007
Location: ------------
Age: 36
Posts: 1,309
Contact Number: ---------------
Program / Discipline: BSIT
Class Roll Number: 07-01
BSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant future
Default Re: Scope of Variables C++

Static Variable

Syntax:
Code:
static int n;
we use static keyword before declaration.

One use of Static Variables is in functions,
when we want to store a value within a function, and not want to destroy it even when the function is ended...
eg: we want to know how many times a function is called.
Code:
void myfunction()
{
static int count=0;
/* Body of Our Function

*/

count++;

}
Static variable count is created when first time we call this function. And is not destroyed until execution of whole program is completed.

when ever we call this function, count is incremented by 1.
So We may easily calculate the number of times a function is executed
Reply With Quote
 

Tags
c++, lectures, scope, variables


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scope of Auditing usmanstar Auditing 0 02-06-2011 10:16 AM
Lecture 22 Multiple Random Variables bonfire Statistics and Probability 0 15-04-2011 01:33 AM
Variables, probability distributions, marginal and joint distributions and density functions bonfire Statistics and Probability 0 15-04-2011 12:11 AM
Concept of random variables, discrete and continuous one and two dimensional random bonfire Statistics and Probability 0 15-04-2011 12:06 AM
Chapter1-Nature and Scope of Economics; Book Fundamental of Economics; Author Sheikh Ramzan .BZU. Economics 0 10-03-2010 06:41 PM

Best view in Firefox
Almuslimeen.info | BZU Multan | Dedicated server hosting
Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.

All times are GMT +5. The time now is 09:03 AM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.