Giter Club home page Giter Club logo

Comments (7)

harttle avatar harttle commented on July 28, 2024

LZ那里应该是int *i = new int吧,另外,定义在函数体中的非动态分配的内存是否会被采用默认的值初始化也依赖与编译器,在我这里的测试中发现g++5.x定义的局部变量也会被默认值初始为0。LZ总结的很棒,博客也很赞哦

By blueyi 2016-05-04T07:20:03Z

from harttle.github.io.

harttle avatar harttle commented on July 28, 2024

嗯,你说的对。一会修改一下~感谢关注!

By Yang Jun 2016-05-04T08:40:19Z

from harttle.github.io.

harttle avatar harttle commented on July 28, 2024

您好楼主,我运行了您的这个程序:

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.

harttle avatar harttle commented on July 28, 2024

c4700是一个warning,参见:https://msdn.microsoft.com/...
一般实践中变量肯定是要初始化的,这个warning的出现也很正常。

By Yang Jun 2016-05-27T03:22:02Z

from harttle.github.io.

Yang-z avatar Yang-z commented on July 28, 2024

int[] arr 是什么鬼,那不是java风格吗?c++什么时候有这种风格了?

from harttle.github.io.

Yang-z avatar Yang-z commented on July 28, 2024

new int[]{1, 2, 3};后面半段也没这这写法啊?我还以为c++有什么改变我不知道,一编译,不通过。。。

from harttle.github.io.

harttle avatar harttle commented on July 28, 2024

感谢!已经改正。

from harttle.github.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.