1. Home
  2. Explore
  3. Computer Science
  4. Bjarne Stroustrup Technology Lecture

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Bjarne Stroustrup Technology Lecture

  • 82Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: C++ Foundations
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What two programming-language traditions were combined to create C++?

Tap to flipClick to flipspace

C, which offers close-to-hardware programming, and Simula, which contributed classes and object-oriented abstractions.

Or swipe the card

82 cards

  1. What two programming-language traditions were combined to create C++?

    C, which offers close-to-hardware programming, and Simula, which contributed classes and object-oriented abstractions.

  2. What was the purpose of adding classes to C?

    To let programmers build their own abstractions, combining data representations with operations and interfaces.

  3. What does C++ aim to preserve from C?

    The ability to map closely to hardware and represent machine operations and data directly.

  4. What did Fortran contribute to the history of programming languages?

    It helped shift programming from machine-focused notation toward notation suited to human problems, especially scientific and engineering work.

  5. What problem did Simula-style classes help address across specialized languages?

    They let programmers define their own abstractions, helping combine kinds of work that separate specialized languages handled poorly together.

  6. Why is type safety an important goal in C++?

    It helps detect incorrect uses of values and functions, ideally before a program runs.

  7. Why does C++ emphasize performance and closeness to hardware?

    It is intended for areas such as systems programming, where programs may need to run efficiently and interact directly with hardware.

  8. What does predictability mean for real-time programming?

    Operations must have predictable execution times; operations without acceptable timing guarantees may not be allowed.

  9. What design principle links code complexity to task complexity?

    The complexity of the code should be proportional to the complexity of the task.

  10. Why does C++ maintain compatibility with older code?

    To avoid breaking large existing codebases that depend on earlier language behavior.

  11. What kinds of software does the speaker identify as C++’s main domain?

    Efficient abstractions for long-lived software infrastructure, systems programming, and resource-constrained applications.

  12. Why can software design require a long time to mature?

    A language or system may take years to reach serious industrial use, followed by further decades of development and use.

  13. What is a resource in systems programming?

    Something a program acquires and must eventually return or release.

  14. What is a resource leak?

    A failure to release a resource after the program is finished using it.

  15. Why should a resource have a clear owner?

    A known owner makes it clear who is responsible for releasing the resource.

  16. What does RAII stand for, and what is its central idea?

    Resource Acquisition Is Initialization: acquire a resource when an object is initialized and release it when the object is destroyed.

  17. How do constructors and destructors support resource management?

    A constructor establishes an object’s valid state and acquires what it needs; a destructor releases its resources.

  18. How does RAII help when a function returns early or throws an exception?

    Local objects are destroyed as the scope is exited, so their destructors release held resources.

  19. What is the role of a resource-managing handle?

    It represents a resource and manages its lifetime, hiding the details of the underlying resource.

  20. How do standard containers and strings commonly manage their contents?

    They manage their own storage and clean it up when the container or string is destroyed.

  21. Why is a raw pointer alone an unclear ownership mechanism?

    It refers to an object but does not say who must destroy it.

  22. Why is garbage collection not a complete solution to resource management?

    It handles memory, but not every resource, and it can introduce shared coordination costs.

  23. What is a common use for pointers and iterators when ownership is handled separately?

    They can refer to objects owned by containers or other resource-managing objects without owning those objects themselves.

  24. What is the purpose of a unique_ptr?

    To represent exclusive ownership of a dynamically allocated object and automatically destroy it when the pointer is destroyed.

  25. What is the purpose of a shared_ptr?

    To manage an object shared by multiple owners and destroy it when the last owner releases it.

  26. What is a potential cost of shared_ptr?

    Maintaining its shared use count can add overhead and coordination between owners.

  27. When is a unique_ptr preferable to a shared_ptr?

    When there is only one owner and shared ownership is unnecessary.

  28. What problem can arise when a function returns a pointer to a newly created object?

    It can be unclear who owns the object and who is responsible for deleting it.

  29. Why can returning a large object by reference be unsafe?

    The reference may refer to an object whose lifetime has ended, and it does not itself explain who owns the object.

  30. What is the purpose of a move constructor?

    To transfer an object’s representation or resources to a new object without copying all of its contents.

  31. How can a move operation transfer a dynamically managed representation?

    It transfers the resource handle to the destination and leaves the source in a state that will not release that resource.

  32. Why are move operations useful when returning large objects?

    They can make returning an object efficient without returning a raw pointer or copying all its elements.

  33. When can the compiler generate useful copy, move, and destruction behavior?

    When an object is composed of members that already know how to copy, move, and clean themselves up.

  34. What is the main design lesson of the matrix-return example?

    Return the matrix as an object and use move semantics when needed, rather than exposing pointer ownership or forcing callers to manage a target object.

  35. When is object-oriented inheritance especially suitable?

    When the concepts in a problem domain have meaningful hierarchical relationships.

  36. What does a virtual function enable in an object hierarchy?

    A call through a base-class interface can invoke the implementation appropriate to the object’s derived type.

  37. What is an abstract class?

    A class that does not provide a complete implementation and is intended to define an interface for derived classes.

  38. What does an explicit override marker communicate?

    That a derived-class function is intended to override a virtual function in a base class.

  39. What is a possible performance drawback of virtual function calls?

    They may make inlining difficult, especially when the operation is small and performance-sensitive.

  40. Why does the speaker caution against using protected data?

    It exposes representation to derived classes, making it harder to preserve the class’s invariants.

  41. Does good programming require using object-oriented inheritance?

    No. Good code can use other styles, and object-oriented code can also be poorly designed.

  42. Why can large inheritance hierarchies become problematic?

    They can make systems difficult to understand and maintain, especially when used without a real hierarchical relationship in the domain.

  43. What is generic programming?

    Writing code that works with different types or containers, provided they support the operations the code requires.

  44. What problem do templates solve for reusable algorithms?

    They let a type or operation be parameterized instead of fixed to one particular type.

  45. What is duck typing in the context of templates?

    A type is accepted if it supports the operations the template uses, whether or not it explicitly declares that it meets a named interface.

  46. When are errors from unsupported template operations often detected?

    At compile time or link time, before the program is shipped.

  47. What is a major drawback of template error messages?

    They can be very long and difficult to connect to the actual mistake in the programmer’s code.

  48. Why are compile-time computations used in generic code?

    They can improve performance and express some work directly before runtime.

  49. What is a function object?

    An object that can be called like a function and can hold state.

  50. What is a lambda expression useful for in generic algorithms?

    It provides a concise way to supply an operation, such as a predicate, directly where an algorithm needs it.

  51. Why do sequence algorithms often use a beginning and an end iterator?

    The pair specifies the range to process, allowing algorithms to work on all or only part of a sequence.

  52. What is the purpose of a predicate in an algorithm?

    It supplies a test or comparison that determines how the algorithm treats elements.

  53. Why are C-style arrays a potential source of errors?

    Their size can be lost when they are treated as pointers, making it difficult to know how many elements are available.

  54. How can a container help avoid array-size problems?

    It can keep track of its elements and expose its size along with access operations.

  55. What problem do concepts aim to solve for templates?

    They let programmers state and check the requirements a template places on its arguments.

  56. What does a concept express about a template argument?

    That the argument supports a specified set of types or operations needed by the template.

  57. Why is a list unsuitable for an algorithm requiring random access?

    A list does not provide direct random access to an element in the way the algorithm requires.

  58. How can concepts improve template diagnostics?

    They can report that an argument fails a named requirement, making the error clearer and shorter.

  59. What is the difference between specifying a template requirement and relying only on duck typing?

    A stated requirement documents and checks the intended interface; duck typing discovers compatibility only from whether the used operations work.

  60. Why does the speaker say generic programming is still programming?

    Generic code uses the same fundamental programming ideas as ordinary code, but applies them to types that meet stated requirements.

  61. How can compile-time functions help replace template metaprogramming?

    They can express computations as ordinary-looking functions that run at compile time, avoiding some complex template techniques.

  62. Why can concepts reduce the need for template metaprogramming?

    They let programmers express requirements directly, so some complicated workarounds become unnecessary.

  63. Can object-oriented and generic programming be used together?

    Yes. Generic algorithms can operate on containers of objects that also use runtime polymorphism.

  64. What does the shapes-and-container example demonstrate about programming styles?

    A single program can combine object-oriented, generic, and functional-style techniques.

  65. Why does the speaker discourage programming-paradigm wars?

    Different techniques are useful for different problems, and language features can make styles easier or harder to express.

  66. Does a newer programming paradigm make older techniques useless?

    No. Older techniques may remain appropriate for many tasks even when newer techniques are available.

  67. What is the danger of writing code at the limit of one’s complexity tolerance?

    The code may be too difficult for its author or others to maintain.

  68. Why can adopting modern C++ features be difficult for organizations?

    Large codebases may need to remain compatible with older compilers or established development procedures.

  69. Why is replacing C++ with a completely new language difficult?

    A new language may lack the existing community, codebase, tools, and infrastructure needed for adoption.

  70. Why are some old C++ features difficult to remove?

    Existing code and paying users may depend on them, so removal could break programs.

  71. What role can static analysis play in modernizing old code?

    It can identify problems and help assess code as teams adopt safer or more modern techniques.

  72. How can code transformation support modernization?

    It can automatically rewrite parts of an old codebase into a newer style.

  73. Why can C++ compilation be slow when headers are repeatedly included?

    The same header contents may be processed again for many source files.

  74. What compilation problem are module systems intended to address?

    Repeated processing of shared declarations and headers across source files.

  75. Why is binary compatibility between C++ compilers difficult?

    Compiler vendors have used different linkage and object-file conventions, and there is no single standardized C++ ABI described in the lecture.

  76. Why do compiler vendors often prioritize compatibility with their own earlier compilers?

    They have customers with large codebases that depend on the behavior and binary conventions of earlier releases.

  77. How can using containers help reduce buffer-overflow risks?

    Containers retain size information and provide access operations that can be used instead of unchecked raw-array access.

  78. What is an out-of-bounds access?

    An attempt to access an element outside the valid range of an array or container.

  79. How can hardware range checking improve program safety?

    It can detect and enforce limits on accesses that go outside valid ranges.

  80. How does using a container’s size help make a loop safer?

    The loop can use the number of elements the container actually holds instead of relying on an assumed array length.

  81. What is the benefit of combining type safety with careful access to system resources?

    It may allow systems to prevent many invalid operations while still operating efficiently.

  82. Why does the speaker reject blaming early C designers alone for modern security bugs?

    The speaker argues that responsibility also lies with people who continue using unsafe coding practices when safer alternatives are available.

Card 1 of 82
Card 1 of 82

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent