草庐IT

目的性

全部标签

c++ - boost::checked_delete 的目的

我不明白boost::checked_delete的目的。文档说:TheC++Standardallows,in5.3.5/5,pointerstoincompleteclasstypestobedeletedwithadelete-expression.Whentheclasshasanon-trivialdestructor,oraclass-specificoperatordelete,thebehaviorisundefined.Somecompilersissueawarningwhenanincompletetypeisdeleted,butunfortunately,no

c++ - boost::checked_delete 的目的

我不明白boost::checked_delete的目的。文档说:TheC++Standardallows,in5.3.5/5,pointerstoincompleteclasstypestobedeletedwithadelete-expression.Whentheclasshasanon-trivialdestructor,oraclass-specificoperatordelete,thebehaviorisundefined.Somecompilersissueawarningwhenanincompletetypeisdeleted,butunfortunately,no

c++ - : "using namespace"?的目的是什么

有令人信服的论据againstusingnamespacestd,那么为什么它被引入到语言中呢?不是usingnamespace打败命名空间的目的?我为什么要写usingnamespace?有什么我不知道的问题可以通过usingnamespace优雅地解决吗?,也许在usingstd::swap的行中成语之类的? 最佳答案 一方面,这是在命名空间中使用运算符重载的方式(例如usingnamespacestd::rel_ops;或usingnamespaceboost::assign;)简洁也是一个强有力的论据。你真的喜欢输入和阅读s

c++ - : "using namespace"?的目的是什么

有令人信服的论据againstusingnamespacestd,那么为什么它被引入到语言中呢?不是usingnamespace打败命名空间的目的?我为什么要写usingnamespace?有什么我不知道的问题可以通过usingnamespace优雅地解决吗?,也许在usingstd::swap的行中成语之类的? 最佳答案 一方面,这是在命名空间中使用运算符重载的方式(例如usingnamespacestd::rel_ops;或usingnamespaceboost::assign;)简洁也是一个强有力的论据。你真的喜欢输入和阅读s

c++ - 向下转型是否会破坏多态性的目的?

今天遇到一个问题,foundhere,这为我提出了这个问题。这是我所了解的伪代码示例:classCar{public:virtualintgoFast()=0;};classFordFocus:publicCar{public:intgoFast(){return35;};};classLamborghini:publicCar{boolroof;public:intgoFast(){return-1/0;//crash};voidretractTheRoof(){roof=0;};};classRichGuy{vectorcars;public:voidgoDrive(){for(i

c++ - 向下转型是否会破坏多态性的目的?

今天遇到一个问题,foundhere,这为我提出了这个问题。这是我所了解的伪代码示例:classCar{public:virtualintgoFast()=0;};classFordFocus:publicCar{public:intgoFast(){return35;};};classLamborghini:publicCar{boolroof;public:intgoFast(){return-1/0;//crash};voidretractTheRoof(){roof=0;};};classRichGuy{vectorcars;public:voidgoDrive(){for(i

c++ - C++中 volatile 成员函数的目的是什么?

C++中volatile成员函数的作用是什么? 最佳答案 要回答有关“volatile成员函数”意味着什么的问题(可能是也可能不是发布问题的人最初的意图),将成员函数标记为const或volatile(或组合的constvolatile)将这些限定符应用于函数中使用的this指针。如标准所述(9.2.1“this指针”):ThetypeofthisinamemberfunctionofaclassXisX*.Ifthememberfunctionisdeclaredconst,thetypeofthisisconstX*,ifthe

c++ - C++中 volatile 成员函数的目的是什么?

C++中volatile成员函数的作用是什么? 最佳答案 要回答有关“volatile成员函数”意味着什么的问题(可能是也可能不是发布问题的人最初的意图),将成员函数标记为const或volatile(或组合的constvolatile)将这些限定符应用于函数中使用的this指针。如标准所述(9.2.1“this指针”):ThetypeofthisinamemberfunctionofaclassXisX*.Ifthememberfunctionisdeclaredconst,thetypeofthisisconstX*,ifthe

c++ - std::byte 的目的是什么?

既然c++17有std::byte,我一直在寻找一种方法,将读取文件的代码转换为char的代码,将文件读取到字节。文件包含字节,而不是一堆整数。然后我读到thisquestion和thisotherquestion人们认为将文件读入byte是错误的,而将文件读入char是正确的。如果byte不是为访问内存而设计的,以此类推,文件,那么它的目的是什么?正如其他两个问题中所引用的那样:Likecharandunsignedchar,itcanbeusedtoaccessrawmemoryoccupiedbyotherobjects(objectrepresentation),butunli

c++ - std::byte 的目的是什么?

既然c++17有std::byte,我一直在寻找一种方法,将读取文件的代码转换为char的代码,将文件读取到字节。文件包含字节,而不是一堆整数。然后我读到thisquestion和thisotherquestion人们认为将文件读入byte是错误的,而将文件读入char是正确的。如果byte不是为访问内存而设计的,以此类推,文件,那么它的目的是什么?正如其他两个问题中所引用的那样:Likecharandunsignedchar,itcanbeusedtoaccessrawmemoryoccupiedbyotherobjects(objectrepresentation),butunli