Git Product home page Git Product logo

Comments (3)

tsyw avatar tsyw commented on May 22, 2024

我的想法是:是不是类名需要声明,而类里面的东西不需要加using

from cppprimer.

pezy avatar pezy commented on May 22, 2024

是不是类名需要声明,而类里面的东西不需要加using

不是,你碰到情况的另有原因。

使用这两个头文件里面定义的东西是不是不需要加using std::size_t; using std::toupper; 之类的声明?

<cctype><cstddef> 你观察到了没,两者都是以 c 开头的,他们原本都是 C语言的库。C++ 为了兼容 C,也将其封入了 STL。

所以当你加上 std 的时候,用的是 STL(c++) 中的函数;当你不加 std 的时候,用的是原生 C 语言的函数。目前绝大部分 C++ 编译器都可以编译 C 程序,所以让你产生了加不加都可以的错觉。

其实,在 C++ 11 之后,加上 std 是比较严谨,恰当的做法。如果我的部分答案没写,应该是疏忽了。回头有空我补上吧。。。

from cppprimer.

tsyw avatar tsyw commented on May 22, 2024

谢谢,看来是我看书不仔细

from cppprimer.

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.