C++ Foundations·Practice drills 7

Drill 16: Inputs and outputs — References and classes

Identify the inputs and outputs of the example.

Intermediate 5 min read Lesson 166 of 300 Challenge included
What you will be able to do
  • Identify the inputs and outputs of the example.

Practice task

Identify the inputs and outputs of the example.

course.cppC++
#include <iostream>
#include <string>
#include <vector>

class Course {
public:
    Course(std::string slug, int lessons)
        : slug_(std::move(slug)), lessons_(lessons) {}

    const std::string& slug() const { return slug_; }
    int lessons() const { return lessons_; }

private:
    std::string slug_;
    int lessons_;
};

void print(const Course& course) {
    std::cout << course.slug() << ": " << course.lessons() << " lessons\n";
}
Your turn

Write your answer

Easy

Identify the inputs and outputs of the example.

TEXT · starter
Your answer…
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Lesson 166 of 300 · 0% of course