+ 3

what is problem in this program(calculator)?

#include<iostream> using namespace std; void getnumber(); int sum(); int mul(); int min(); int min(); float div1(); int a,b; int main(){ char ch; while(1){ cout<<"\n g=get + - / *\n"; cin>>ch; switch(ch){ case 'g':getnumber(); break; case '+':{ int m; m=sum(); cout<<"sum is= "<<m; break; case '-': cout<<"min is ="<<min(); break; case'×':cout<<"mul is="<<mul(); break; error compile no previous extern declaration for non _static variable a

24th Mar 2017, 4:08 PM
sam
1 Answer
+ 10
You've declared "a" outside of main(),. Only static variables can be used outside the scope of main(). (edit). You probably have other files being linked, which is why it needs to be named as extern beforehand.
24th Mar 2017, 4:12 PM
Karl T.
Karl T. - avatar