FlashKeepers

C and C++ · College · College and University

C++ I: Basics and References

C++ syntax beyond C, namespaces, references, const correctness, std::string, std::vector basics, streams and function overloading.

About this set

40 basic cards for College C and C++. Set 1 of 7 in C++. It opens with "What is a namespace in C++?" and "How do you declare a namespace?". Study it alongside the other College sets below.

40 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is a namespace in C++?
Show answerA scope region that holds a set of identifiers to avoid naming conflicts between different parts of code or libraries
How do you declare a namespace?
Show answernamespace NamespaceName { /* declarations */ }
How do you access a member of a namespace?
Show answerUse the scope resolution operator: NamespaceName::memberName
What does 'using namespace std;' do?
Show answerBrings all names from the std namespace into the current scope, so you can use them without the std:: prefix
What is a reference in C++?
Show answerAn alias to an existing variable that acts like another name for that variable
What is the syntax for declaring a reference?
Show answerType& referenceName = existingVariable;
Can a reference be null in C++?
Show answerNo, a reference must always refer to a valid object and cannot be null
Can a reference be reassigned to refer to a different variable?
Show answerNo, once a reference is bound to a variable, it always refers to that same variable
What is the main difference between a reference and a pointer?
Show answerReferences cannot be null, cannot be reassigned, and do not require dereferencing; pointers can be all three
What is a const reference?
Show answerA reference to a constant that prevents modification of the referenced object through that reference
What is const correctness in C++?
Show answerUsing the const keyword appropriately to prevent unintended modifications and make intent explicit
Are 'int const x' and 'const int x' equivalent?
Show answerYes, both declare a constant integer; const can appear before or after the type
What does 'const' on a function parameter do?
Show answerPrevents the function from modifying the parameter
What is std::string?
Show answerA standard library class that represents a dynamic sequence of characters
Which header must you include to use std::string?
Show answer#include <string>

25 more cards in the app

Study this set free