惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - abraham

I want learn the programming web by C#.Who can give a simple step by step tutorial,please? Today begin new life of blog. I want learn the programming web by C#.Who can give a simple step by step tutorial,please? Today begin new life of blog. create dll formt lib with cpp funcs or c just funcs by hand. pub class into dll in dos by hand step by step. put class into dll by using vc6.0 How To Read a Big Txt File into CEdit and write it as save!. Create a Dlg's Thread and use it,this can use dlg handle. Create a Thread and Use it. Here is a reason why can not log a SQL CString How to Kill Blanks in a CString,but how to kill Chinese Blanks i can not solve. How to get a Chinese character's PinYin automaticly? PE format is very important,so learn it. create a dll by hand. STL is very important,so we learn. print a bmp 2 - abraham Create COM step by step 2. - abraham Create com step by step.1
static/register/atuo/extern/volatile/const
abraham · 2004-03-31 · via 博客园 - abraham

static

l         静态变量作用范围在一个文件内,程序开始时分配空间,结束时释放空间,默认初始化为0,使用时可改变其值。

l         静态变量或静态函数,即只有本文件内的代码才可访问它,它的名字(变量名或函数名)在其它文件中不可见。

l         在函数体内生成的静态变量它的值也只能维持

int max_so_far( int curr )//求至今(本次调用)为止最大值

{

   static int biggest; //该变量保持着每次调用时的最新值,它的有效期等于整个程序的有效期

   if( curr > biggest )

      biggest = curr;

   return biggest;

}

l         C++类的成员变量被声明为static(称为静态成员变量),意味着它为该类的所有实例所共享,也就是说当某个类的实例修改了该静态成员变量,其修改值为该类的其它所有实例所见;而类的静态成员函数也只能访问静态成员(变量或函数)。

l         类的静态成员变量必须在声明它的文件范围内进行初始化才能使用,private类型的也不例外。如,
               float SavingsAccount::currentRate = 0.00154;
   (注:currentRate是类SavingsAccount的静态成员变量)

register

l         register声明的变量称着寄存器变量,在可能的情况下会直接存放在机器的寄存器中;但对32位编译器不起作用,当global optimizations(全局优化)开的时候,它会做出选择是否放在自己的寄存器中;不过其它与register关键字有关的其它符号都对32位编译器有效。

auto

l         它是存储类型标识符,表明变量(自动)具有本地范围,块范围的变量声明(如for循环体内的变量声明)默认为auto存储类型。

extern

l         声明变量或函数为外部链接,即该变量或函数名在其它文件中可见。被其修饰的变量(外部变量)是静态分配空间的,即程序开始时分配,结束时释放。用其声明的变量或函数应该在别的文件或同一文件的其它地方定义(实现)。在文件内声明一个变量或函数默认为可被外部使用。

l         C++中,还可用来指定使用另一语言进行链接,这时需要与特定的转换符一起使用。目前Microsoft C/C++仅支持”C”转换标记,来支持C编译器链接。使用这种情况有两种形式:

u       extern “C” 声明语句

u       extern “C” { 声明语句块 }

volatile

l         限定一个对象可被外部进程(操作系统、硬件或并发线程等)改变,声明时的语法如下:

int volatile nVint;

       这样的声明是不能达到最高效的,因为它们的值随时会改变,系统在需要时会经常读写这个对象的值。       只常用于像中断处理程序之类的异步进程进行内存单元访问。

const

l         const所修饰的对象或变量不能被改变,修饰函数时,该函数不能改变在该函数外面声明的变量也不能调用任何非const函数。在函数的声明与定义时都要加上const,放在函数参数列表的最后一个括号后。

l         C++中,用const声明一个变量,意味着该变量就是一个带类型的常量,可以代替#define,且比#define多一个类型信息,且它执行内链接,可放在头文件中声明;但在C中,其声明则必须放在源文件(即.C文件)中,在Cconst声明一个变量,除了不能改变其值外,它仍是一具变量,如

const int maxarray = 255;

char store_char[maxarray];  //C++中合法,C中不合法

l         const修饰指针时要特别注意。例:

char *const aptr = mybuf;  // 常量指针
*aptr = 'a';       // Legal
aptr = yourbuf;    // Error
const char *bptr = mybuf;  // (指针bptr)指向常量数据
*bptr = 'a';       // Error
bptr = yourbuf;    // Legal
l         const修饰成员函数时不能用于构造和析构函数。