static关键字

his is my code what i writted for the Comprehensive quiz. After i was done with it and tested that it works ( and it worked as it needed ) i checked out the solution but sawed that i do did it in an other way. I want you if you have some time that to check down the code and what do you think about it.
Im totally new in this C++ programming, started with your tutorial just a few days ago but i learned java in scool so probably its recogniseable in my codeing :D .

#include
#include

using namespace std;

int main()
{
double nNumberOne = 0;
double nNumberTwo = 0;
char nSymbol;
double nEredmeny = 0;

cout <> nNumberOne ;
cout <> nNumberTwo ;
cout <> nSymbol;
if (nSymbol == ‘+’ ){
nEredmeny = nNumberOne + nNumberTwo;

cout << nNumberOne <<" + " << nNumberTwo << " = " << nEredmeny;
}

if (nSymbol == '-' ){
nEredmeny = nNumberOne – nNumberTwo;

cout << nNumberOne <<" – " << nNumberTwo << " = " << nEredmeny;
}

if (nSymbol == '*' ){
nEredmeny = nNumberOne * nNumberTwo;

cout << nNumberOne <<" * " << nNumberTwo << " = " << nEredmeny;
}

if (nSymbol == '/'){
nEredmeny = nNumberOne / nNumberTwo;

cout << nNumberOne <<" / " << nNumberTwo << " = " << nEredmeny;

在前人的经验教训,你了解了局部变量(有块范围)和全局变量(有计划的范围)。还有另一个作用域的变量,可以水平:文件范围。

文件范围内的变量可以被访问的任何功能或嵌在一个单一的文件。申报文件作用域的变量,简单地声明一个变量,一块外(同一个全局变量)但使用static关键字:

1
2
3
4
5
6
7
static int nValue; // file scoped variable
float fValue; // global variable
 
int main()
{
    double dValue; // local variable
}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值