standards

Why the ISO C++ standard forbids the initialization for members? [closed]

六月ゝ 毕业季﹏ 提交于 2019-12-04 10:35:18
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Why i can't do that class A { public: int x = 10; ... }; and I have to do that ? class A { public: int x; A(){ x = 10; ... } ... }; It's because C++ is trying to be more type safe than languages like C ? There are other reasons ? This

hiding of template parameter of member template

Deadly 提交于 2019-12-04 10:25:41
问题 from temp.local : In the definition of a member of a class template that appears outside of the class template definition, the name of a member of the class template hides the name of a template-parameter of any enclosing class templates ( but not a template-parameter of the member if the member is a class or function template ). [ Example: template<class T> struct A { struct B { /* ... */ }; typedef void C; void f(); template<class U> void g(U); }; template<class B> void A<B>::f() { B b; //

Mystical restriction on std::binary_search

狂风中的少年 提交于 2019-12-04 09:55:47
问题 Problem description: Consider some structure having an std::string name member. For clearness let's suppose that it's a struct Human , representing information about people. Besides the name it can also have many other data members. Let there be a container std::vector<Human> vec , where the objects are already sorted by name . Also for clearness suppose that all the names are unique. The problem is : having some string nameToFind find out if there exists an element in the array having such

C++: Calculate number of possible floating-point values within given range

跟風遠走 提交于 2019-12-04 09:35:14
I'm working on a cryptography application ,using Crypto++ As an obscure part of this application, I need to determine the maximum number of unique float values that can exist within a certain numeric range. Obviously there are infinite numbers between 0 and 1 in reality - but not all of them can be represented by a unique float value. I have a minimum float value, and a maximum float value. I need to determine the number of possible float values inside this range. This is tricky, because floating-point values are spaced further apart, the farther you get from 0 . For example, the number of

Before XML became a standard and given all its shortcomings, what made XML so popular?

我与影子孤独终老i 提交于 2019-12-04 09:10:53
问题 Yes XML is human readable but so is comma delimited text and properties files. XML is bloated, hard to parse, hard to modify in code, plus a ton of other problems that I can think about with it. My questions is what are XML's most attractive qualities that has made it so popular???? 回答1: One of the major advantages it has over things like CSV files is that it can represent hierarchical data easily. To do this you either need a self-describing tree structure like XML, or a pre-defined format

IE9 letter-spacing problem

ぐ巨炮叔叔 提交于 2019-12-04 09:01:18
问题 I have a page that renders ok, in FF (3x, 4x), Chrome, IE (6, 7, 8). When tested on IE9 the texts are wider. Investigating the problem it appears that the text is actually rendered whith letters more spaciated than in other borwsers. When changed the letter spacing to -0.6px the texts was rendered ok, similar to other browsers. Also when changed the render mode to "Compatibility view", the page looks just fine. Do you know what caused the change in the render mode? I "solved" the issue using

Does the C standard have a website for defect reports?

徘徊边缘 提交于 2019-12-04 08:55:58
问题 In my previous question, the discussion seems to imply that there might be a defect in the C standard, further implied by the top answerer's last sentence: The authors of the standard merely neglected to say so. I'm aware that C++ has an online website where you can search for defect reports, i.e. here is my search for null pointer constant, but is there something similar for the C standard? 回答1: Keeping up with the C standards process is not as convenient as keeping up with the C++ process

C11 Standard docs

时光总嘲笑我的痴心妄想 提交于 2019-12-04 08:16:57
问题 Starting from this SO protected question I'm trying to understand what the difference between those documents: 9899 2012 costs $60 9899 2011 costs $265 As you can see those documents have very different prices and I don't know if the cheaper one is valid or is something like draft or cut copy of the real standard. Did someone buy the INCITS one? EDIT As @Chqrlie pointed out: What is the difference between the ANSI and ISO official documents available for a free and the final draft freely

C# read-only calculated properties, should they be methods?

末鹿安然 提交于 2019-12-04 07:57:38
问题 I have several entities that have calculated fields on them such as TotalCost. Right now I have them all as properties but I'm wondering if they should actually be methods. Is there a C# standard for this? public class WorkOrder { public int LaborHours { get; set; } public decimal LaborRate { get; set; } // Should this be LaborCost()? public decimal LaborCost { get { return LaborHours * LaborRate; } } } 回答1: It's OK to use calculated properties rather than methods, as long as the calculation

Which PDF of the C++ ISO standard should I read? [duplicate]

自作多情 提交于 2019-12-04 07:52:49
This question already has answers here : Where do I find the current C or C++ standard documents? (12 answers) Closed 6 years ago . Sometimes, I want to search answers from the C++ standard by myself. Reading standards might help me get an overview of the language principle proposed. By searching the internet, I was confused by flooding C++ forums and helper websites. They provide all kinds of PDF files for reading. I don't know which PDF file and/or which version should I adopt. I found several websites: JTC1/SC22/WG21 Standing Documents I wonder whether there is a single site where the