¡@

Home 

c++ Programming Glossary: so

What are the rules about using an underscore in a C++ identifier?

http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier

identifier It's common in C to name member variables with some kind of prefix to denote the fact that they're member variables.. from an MFC background you'll probably use m_foo . I've also seen myFoo occasionally. C# or possibly just .NET seems to recommend.. namespaces identifiers beginning with an underscore Also everything in the std namespace is reserved. You are allowed..

What can I use to profile C++ code in Linux?

http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux

times and each time look at the call stack. If there is some code that is wasting some percentage of the time 20 or 50.. at the call stack. If there is some code that is wasting some percentage of the time 20 or 50 or whatever that is the probability.. summaries in the presence of recursion. They will also say it only works on toy programs when actually it works on..

What is The Rule of Three?

http://stackoverflow.com/questions/4172722/what-is-the-rule-of-three

actually means. Let us consider a simple example class person std string name int age public person const std string name.. example class person std string name int age public person const std string name int age name name age age int main person.. std string name int age name name age age int main person a Bjarne Stroustrup 60 person b a What happens here b a And..

Undefined Behavior and Sequence Points

http://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points

chatroom where the FAQ idea started out in the first place so your answer is very likely to get read by those who came up.. What are side effects Evaluation of an expression produces something and if in addition there is a change in the state of.. it is said that the expression its evaluation has some side effect s . For example int x y where y is also an int..

Operator overloading

http://stackoverflow.com/questions/4421706/operator-overloading

were given in a specific order but since many users sort answers according to votes rather than the time they were.. Input and Output Operators Function call operator Comparison operators Arithmetic Operators Array Subscription Operators.. chatroom where the FAQ idea started out in the first place so your answer is very likely to get read by those who came up..

How do I use arrays in C++?

http://stackoverflow.com/questions/4810664/how-do-i-use-arrays-in-c

prone std vector T since C 98 and std array T n since C 11 so the need for arrays does not arise quite as often as it does.. of pointers common pitfalls when using arrays If you feel something important is missing in this FAQ write an answer and.. chatroom where the FAQ idea started out in the first place so your answer is very likely to get read by those who came up..

Where and why do I have to put the “template” and “typename” keywords?

http://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords

dependent name and VC is quite right in choking on it. I also know that I should be able to add template somewhere to tell.. on it. I also know that I should be able to add template somewhere to tell the compiler that inUnion is a template id. But.. float to std string is a compile time error. The simple solution was to add a template typename U struct inUnion . The..

Can a local variable's memory be accessed outside its scope?

http://stackoverflow.com/questions/6441218/can-a-local-variables-memory-be-accessed-outside-its-scope

you to break the rules of the system. If you try to do something illegal and foolish like going back into a room you're.. anymore C is not going to stop you. Safer languages than C solve this problem by restricting your power by having much stricter.. techniques have become entrenched. The first is to have some sort of long lived storage area where the lifetime of each..

Why is processing a sorted array faster than an unsorted array?

http://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-an-unsorted-array

thought this might be just a language or compiler anomaly. So I tried it in Java import java.util.Arrays import java.util.Random.. appropriately. Trains are heavy and have a lot of inertia. So they take forever to start up and slow down. Is there a better.. Modern processors are complicated and have long pipelines. So they take forever to warm up and slow down . Is there a better..

What is the slicing problem in C++?

http://stackoverflow.com/questions/274626/what-is-the-slicing-problem-in-c

is the slicing problem in C Someone mentioned it in the IRC but google doesn't have a good.. away. For example class A int foo class B public A int bar So an object of type B has two data members foo and bar Then if..

What is the copy-and-swap idiom?

http://stackoverflow.com/questions/3279543/what-is-the-copy-and-swap-idiom

in a state guaranteed to be assignable and destructible. So what we've done is simple initialize via the default constructor..

What can I use to profile C++ code in Linux?

http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux

that you will catch it in the act on each sample. So that is roughly the percentage of samples on which you will.. says P f 0.5 is 26 up from the prior assumption of 0.6 . So Bayes allows us to update our estimate of the probable cost.. see it once that doesn't tell us much except that f 0. So even a very small number of samples can tell us a lot about..

What is The Rule of Three?

http://stackoverflow.com/questions/4172722/what-is-the-rule-of-three

direct ... members n3126.pdf 12.4 §6 Managing resources So when should we declare those special member functions explicitly.. that manage resources is hard. Noncopyable resources Some resources cannot or should not be copied such as file handles.. person operator const person that delete The rule of three Sometimes you need to implement a class that manages a resource...

Undefined Behavior and Sequence Points

http://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points

question Disclaimer Okay. This answer is a bit long. So have patience while reading it. If you already know these things.. of y gets changed due to the side effect of operator. So far so good. Moving on to sequence points. An alternation definition.. involved in computation of the value to be written. So it is fine. This rule effectively constrains legal expressions..

Operator overloading

http://stackoverflow.com/questions/4421706/operator-overloading

for member functions will be this needs to be const too. So a comparison operator implemented as a member function would..

What are the differences between pointer variable and reference variable in C++?

http://stackoverflow.com/questions/57483/what-are-the-differences-between-pointer-variable-and-reference-variable-in-c

a pointer and places the address of i into that storage. So pointer and reference occupies same amount of memory As a general..

Where and why do I have to put the “template” and “typename” keywords?

http://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords

if it's a non type it will be parsed as an expression. So the draft Standard says at 3.7 Some names denote types or templates... parsed as an expression. So the draft Standard says at 3.7 Some names denote types or templates. In general whenever a name.. Expressions may depend by their value and or their type. So we have with typical examples appended Dependent types e.g a..

Can a local variable's memory be accessed outside its scope?

http://stackoverflow.com/questions/6441218/can-a-local-variables-memory-be-accessed-outside-its-scope

anything can happen . The book can be there you got lucky. Someone else's book can be there and yours could be in the hotel's.. can be there and yours could be in the hotel's furnace. Someone could be there right when you come in tearing your book.. with a room number higher than you has checked out. So let's think about the stack. In many operating systems you get..

Is gcc4.7 buggy about regular expressions? [duplicate]

http://stackoverflow.com/questions/12530406/is-gcc4-7-buggy-about-regular-expressions

the question. Edit Since people keep complaining on SO about libstdc 's regex code here's an explanation of why it's.. unfinished state since it was added. Reading comments on SO might imply otherwise but the code doesn't actually do anyone.. because anyone who wants to can use Boost.Regex a few SO users trying to write toy programs to test std regex are not..

What are POD types in C++?

http://stackoverflow.com/questions/146452/what-are-pod-types-in-c

are POD types in C I've been following SO for a bit now and I've come across this term POD type a few..

Unnamed/anonymous namespaces vs. static functions

http://stackoverflow.com/questions/154469/unnamed-anonymous-namespaces-vs-static-functions

the exact same thing. For more discussion please see this SO question. Unnamed namespaces still have the advantage of allowing.. to define translation unit local types. Please see this SO question for more details. Credit goes to Mike Percy for bringing..

C state-machine design

http://stackoverflow.com/questions/1647631/c-state-machine-design

one of my worker thread. I was wondering if you gurus on SO would share your state machine design techniques. NOTE I am.. UPDATED Based on all the great input gathered on SO I've settled on this architecture c c design architecture state..

What platforms have something other than 8-bit char?

http://stackoverflow.com/questions/2098149/what-platforms-have-something-other-than-8-bit-char

other than 8 bit char Every now and then someone on SO points out that char aka 'byte' isn't necessarily 8 bits . It..

C++ performance challenge: integer to std::string conversion

http://stackoverflow.com/questions/4351371/c-performance-challenge-integer-to-stdstring-conversion

way using stringstream http ideone.com jh3Sa sprintf which SO ers usually recommend to the performance conscious http ideone.com.. on gcc. Further entries are closed due to the whims of the SO community. The current final speed champions are For gcc user434507..

Pretty-print C++ STL containers

http://stackoverflow.com/questions/4850473/pretty-print-c-stl-containers

return o Now I've seen plenty of template magic here on SO that I never thought possible so I'm wondering if anyone can.. std pair S T . Update This is now a separate question on SO Upupdate This has now been implemented thanks to Xeo Add namespaces..

Operator Precedence vs Order of Evaluation

http://stackoverflow.com/questions/5473107/operator-precedence-vs-order-of-evaluation

return value of the last printf is stored in myval . In SO IEC 9899 201x under J.1 Unspecified behavior it mentions The..

C++ alternative tokens?

http://stackoverflow.com/questions/555505/c-alternative-tokens

in a question a couple weeks ago somewhere here on SO but I can't get SO's search or Google to find the damn thing... a couple weeks ago somewhere here on SO but I can't get SO's search or Google to find the damn thing. share improve this..

What is more efficient i++ or ++i? [duplicate]

http://stackoverflow.com/questions/561588/what-is-more-efficient-i-or-i

been a couple years and I would like to get input from the SO community. java c performance post increment pre increment..

What exactly is “broken” with Microsoft Visual C++'s two-phase template instantiation?

http://stackoverflow.com/questions/6273176/what-exactly-is-broken-with-microsoft-visual-cs-two-phase-template-instanti

instantiation Reading questions comments and answers on SO I hear all the time that MSVC doesn't implement two phase template..

WChars, Encodings, Standards and Portability

http://stackoverflow.com/questions/6300804/wchars-encodings-standards-and-portability

and Portability The following may not qualify as a SO question if it is out of bounds please feel free to tell me..

What breaking changes are introduced in C++11?

http://stackoverflow.com/questions/6399615/what-breaking-changes-are-introduced-in-c11

has a section for incompatibilities at appendix C.2 C and ISO C 2003 . Summary paraphrasing the FDIS here to make it better.. paraphrasing the FDIS here to make it better suitable as a SO answer. I added some examples of my own to illustrate the differences...

Difference between private, public, and protected inheritance in C++

http://stackoverflow.com/questions/860339/difference-between-private-public-and-protected-inheritance-in-c

private public and protected inheritance in C I looked in SO and couldn't find a good description regarding the difference..