Difference between static global and global?

Answers were Sorted based on User's Feedback



Difference between static global and global?..

Answer / mukesh

global variable is accessed in all file by use extern keyword.while static global only visible in file in which it is declared.

Is This Answer Correct ?    0 Yes 0 No

Difference between static global and global?..

Answer / nischal bansal

Static global variable can be used only in the file, it is
declared whereas global variable can be used in other files
also. we have to include the file, in which we have
declared the variable

Is This Answer Correct ?    2 Yes 3 No

Difference between static global and global?..

Answer / sheela

hello...

what r all above said is false. global static also can
access using extern in other files.

file 1:

#include<stdio.h>
#include <conio.h>
#include "file2.c"
int a=10;
static int b=20;
main()
{
send();
}


file 2:


#include<stdio.h>
#include<conio.h>

void send()
{
extern int a;
extern int b;
printf("%d%d",a,b);
getch();
}


this program prints both a and b values.. then how can u
say global statics has file scope.

please if anybody knows correct answer give me.

Is This Answer Correct ?    0 Yes 1 No

Difference between static global and global?..

Answer / chitra

static global is fixed.but global variables are changed.

Is This Answer Correct ?    7 Yes 88 No

Difference between static global and global?..

Answer / afroz

there is no any diffrence between static and non static
global variable

Is This Answer Correct ?    16 Yes 115 No

Difference between static global and global?..

Answer / priya

static means fixed we should not change anything,but in non
static we can change.

Is This Answer Correct ?    5 Yes 106 No

Post New Answer

More C++ General Interview Questions

write infinite loop in C++ which does not use any variable or constant?

3 Answers  


How the endl and setw manipulator works?

0 Answers  


Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- &#9474; &#9474; &#9474; &#9474; &#9474; &#9474; ---

0 Answers  


Write a program using GUI concept for the scheduling algorithms in Operating system like SJF,FCFS etc..

0 Answers  


C++ program output? Explain output of this program. #include <iostream> using std::cout; using std::cin; int main() {   cout<<cout<<' ';   cout<<cin;   return 0; } It prints some address in hexadecimal. what is it?

1 Answers  






Is python written in c or c++?

0 Answers  


Differentiate between a copy constructor and an overloaded assignment operator.

0 Answers  


What are the advantages of using typedef in a program?

0 Answers  


What happens when the extern "c" char func (char*,waste) executes?

0 Answers  


Explain the properties and principles of oop.

0 Answers  


Why do we use using namespace std in c++?

0 Answers  


How should runtime errors be handled in c++?

0 Answers  


Categories