Q2 Flashcards

1
Q

In the following custom type, which member is a query?

struct Movie
{
    char m_title[32];
    const double m_price;
    void setTitle(const char* title);
    double getPrice() const;
};
A

getPrice

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which functions are allowed to modify private data in a custom type named Foo?

A

Only member functions of Foo.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which of the following is the insertion operator?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an empty state?

A

It’s a special state for an object that signals the object doesn’t contain valid data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which of the following is the extraction operator?

A

> >

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

For the following custom type, what is correct way to define the member function getTitle in the cpp file?

A
const char* TvShow::getTitle() const
{
    /* implementation */
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Regarding the following code

class Book
{
    char m_title[32];
    double m_price;
    int getNumberOfWords(const int& page) const;
};  

which statement is true?

A

The function getNumberOfWords() cannot change the state of the object or the parameter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a difference between a C++ class and a C++ struct?

A

Members of the class are private by default, while members of the struct are public by default.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which object is used in C++ to read data from the keyboard?

A

cin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly