These are questions about C++ Style and Technique that people ask me often. If you have better questions or comments on the answers, feel free to email me (bs@research.att.com). Please remember that I can't spend all of my time improving my homepages. For more general questions, see my general FAQ.For terminology and concepts, see my C++ glossary.Please note that these are just a collection of questions and answers. They are not a substitute for a carefully selected sequence of examples and explanations as you would find in a good textbook. Nor do they offer detailed and precise specifications as you would find in a reference manual or the standard. See The Design and Evolution of C++ for questions related to the design of C++. See The C++ Programming Language for questions about the use of C++ and its standard library. Topics:
QR:
- Getting started
- Classes
- Hierarchy
- Templates and generic programming
- Memory
- Exceptions
- Other language features
- Trivia and style
- Getting started:
- Classes:
- Class hierarchies:
- Why do my compiles take so long?
- Why do I have to put the data in my class declarations?
- Why are member functions not virtual by default?
- Why don't we have virtual constructors?
- Why are destructors not virtual by default?
- What is a pure virtual function?
- Why doesn't C++ have a final keyword?
- Can I call a virtual function from a constructor?
- Can I stop people deriving from my class?
- Why doesn't C++ have a universal class Object?
- Do we really need multiple inheritance?
- Why doesn't overloading work for derived classes?
- Can I use "new" just as in Java?
- Templates and generic programming:
- Why can't I define constraints for my template parameters?
- Why can't I assign a vector<Apple> to a vector<Fruit>?
- Is "generics" what templates should have been?
- why use sort() when we have "good old qsort()"?
- What is a function object?
- What is an auto_ptr and why isn't there an auto_array?
- Why doesn't C++ provide heterogenous containers?
- Why are the standard containers so slow?
- Memory:
- How do I deal with memory leaks?
- Why doesn't C++ have an equivalent to realloc()?
- What is the difference between new and malloc()?
- Can I mix C-style and C++ style allocation and deallocation?
- Why must I use a cast to convert from void*?
- Is there a "placement delete"?
- Why doesn't delete zero out its operand?
- What's wrong with arrays?
- Exceptions:
- Other language features:
- Can I write "void main()"?
- Why can't I overload dot, ::, sizeof, etc.?
- Can I define my own operators?
- How do I call a C function from C++?
- How do I call a C++ function from C?
- Why does C++ have both pointers and references?
- Should I use NULL or 0?
- What's the value of i++ + i++?
- Why are some things left undefined in C++?
- What good is static_cast?
- So, what's wrong with using macros?
- Trivia and style:
QR:
0 comments:
Post a Comment