Comments (7)
LZ那里应该是int *i = new int吧,另外,定义在函数体中的非动态分配的内存是否会被采用默认的值初始化也依赖与编译器,在我这里的测试中发现g++5.x定义的局部变量也会被默认值初始为0。LZ总结的很棒,博客也很赞哦
By blueyi 2016-05-04T07:20:03Z
from harttle.github.io.
嗯,你说的对。一会修改一下~感谢关注!
By Yang Jun 2016-05-04T08:40:19Z
from harttle.github.io.
您好楼主,我运行了您的这个程序:
int g_var;
int *g_pointer;
static int g_static;
int main(){
int l_var;
int *l_pointer;
static int l_static;
cout<<g_var<<endl<<g_pointer<<endl<<g_static<<endl; cout<<l_var<<endl<<l_pointer<<endl<<l_static<<endl;="" }="" 多了个分号不说,但是有错误产生:="" error="" c4700:="" 使用了未初始化的局部变量“l_pointer”="" error="" c4700:="" 使用了未初始化的局部变量“l_var”="" 编译环境为vs2013,使用devc++不会报错,如果这样的话,那到底c++语法是怎么定义的?="" 我该怎么办?="">
By Lynn 2016-05-26T09:20:05Z
from harttle.github.io.
c4700是一个warning,参见:https://msdn.microsoft.com/...
一般实践中变量肯定是要初始化的,这个warning的出现也很正常。
By Yang Jun 2016-05-27T03:22:02Z
from harttle.github.io.
int[] arr 是什么鬼,那不是java风格吗?c++什么时候有这种风格了?
from harttle.github.io.
new int[]{1, 2, 3};后面半段也没这这写法啊?我还以为c++有什么改变我不知道,一编译,不通过。。。
from harttle.github.io.
感谢!已经改正。
from harttle.github.io.
Related Issues (20)
- 2016/10/25/install-oh-my-zsh-locally HOT 2
- 2019/12/26/keep-terminal-cwd HOT 1
- 2015/11/12/vim-tabpage HOT 2
- 2020/06/26/bash-quote-escape HOT 2
- 2020/07/04/4k-device HOT 3
- 2016/07/25/vim-registers HOT 3
- 2020/01/27/secure-cookies HOT 2
- typo in filename
- 2015/10/08/cpp11 HOT 1
- 2019/05/01/linux-macbook-trackpad-settings HOT 2
- 2013/11/08/vim-config HOT 1
- 2015/08/23/effective-cpp-25 HOT 1
- 2016/06/08/shell-config-files HOT 2
- 2020/02/10/deep-into-vue-ssr HOT 1
- 2022/03/19/vim-copy-paste HOT 2
- 2018/03/25/https-protocols HOT 1
- 2022/05/02/ssh-port-forwarding HOT 1
- 2020/06/25/status-code-matters HOT 2
- 2015/09/09/effective-cpp-42 HOT 3
- 2015/08/29/effective-cpp-31 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from harttle.github.io.