FAQ: Classes and Objects - Class Members

This community-built FAQ covers the “Class Members” exercise from the lesson “Classes and Objects”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn C++

FAQs on the exercise Class Members

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Learn more about how to use this guide.

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Moderators - there is a bug in this exercise.

The following is shown with the correct code:

I recommend going through it to see for yourself.

Here’s some screenshots of my code that generates the “Does Song have public: in it?” error.

When you view the solution it’s the exact same code but works…


If I remove the comment

// methods

it works…


Unfortunately unhelpful error message. Same happened to me (I didn’t declare the parameter’s type).

Same for me on that exercise… Frustrating as I had it all correct and was staring at it for an hour wondering what I had done wrong.

This was a poorly-done lesson.

The example for creating a class has the keyword “class”, as in:

class Song {

but the first hint says:

`Song` should be structured like this:
Song {

So does the keyword “class” belong there or not?


Instruction #2 says to make a new method:

`.add_title()` , a `void` method which accepts a `new_title` for a song. (Make sure this parameter has a different name than `title` .)

with no discussion about the leading dot.

Worse, we’re left to guess about the type for this method’s parameter. Is new_title a new type we haven’t come across before? It obviously isn’t supposed to be the name of the parameter, because the next line tells us to use (i.e., choose) a name other than “title”. If my choice of a name is part of the assignment, then this “new_title” phrase you’ve given me must be something different, such as that new type I’m wondering about, that I don’t remember reading about, and can’t find any information about. (The “Show solution” option eventually showed me that this was indeed supposed to be the name of the parameter. Why then tell me to use some name other than “title” as the parameter, if you’re going to tell me what name to use?)


The resources on this lesson’s page do not provide enough information to sort out these issues, so the only real solution is to choose the option to “Show the solution”. But that shows the solution for all of the steps in this lesson, which means the third step in this lesson gets completely skipped; I didn’t have a chance to even begin to look at that part of the challenge.


Later, after I had written most of this comment, I went back and looked at the third instruction’s solution (as I hadn’t yet had a chance to even begin to think about it / look at it before the lesson was over for me (see above)), and I see that I would have been confused about it because of the scope of “title”. There really should have been some discussion about the scope of attributes within a class; I saw

title = new_title

and wondered, “Where did ‘title’ come from?! It’s not defined/declared here in this method. And how does it get out of here back to the method/function call? There’s no “return title” statement. Is it a global variable?”

So i went back and looked around, and was reminded that it is in the attribute section of the “class Song”, and then realized those attributes must have global scope in all things “Song”-ish. Some discussion on these matters would have been helpful.


This whole exercise (as well as the previous one, but not as badly) feels like the author was in a hurry to leave work that day, and settled with doing a poorly-executed rush job.


I found this resource on the internet which will be helpful to understand classes easily


Agreed. This lesson felt like I skipped a couple lessons. There were so many things unexplained. It didn’t make sense.

1 Like

what is the actual solution for part 2?? I’m still getting the error:
“Does ‘Song’ have a member function ‘.add_title()’ declared?”

Here’s my code


// add the Song class here:

class Song{

std::string title;


void add_title(std::string new_title){

std::string get_title(){


1 Like

I really hope they get someone more experienced or better at explaining the process for this… It was terribly done. It sucks having to skip over this lesson. I’d be even more upset if I were paying for premium and had to read over this disaster.


The sad thing is i am paying for premium and i have this ish to go over… im just sad at this point… im going to snip the problem and the error code and then look at the solution, wish me luck in future problems like this… :neutral_face::neutral_face::neutral_face::neutral_face::confused::confused:

1 Like

Literally all you needed to do. Thanks

It confuses me as well… fortunately got my way out of this problem within a few minutes

Please redesign this lesson, it’s been over a year that complaints have been made and as far as I’m aware, no changes have been made to it.
People are paying good money for good lessons.

1 Like

good thing we didn’t pay for this course (and will never due to bad design).

The “.” operator was poorly explained in this lesson and its use needs to be clarified.

The instructions on methods explicitly state to include the “.” before the method name but does not say that this only applies when calling the method and not while declaring or defining it. The following screenshot then shows an example of a method being declared without the “.” operator, seemingly contradicting the previous instructions. Then when we get into the activity itself where the user is told to include the methods “.get_title()” and “.new_title()”. Both using the “.” operator, once again seeming to contradict the screenshot example.

All that is needed is a quick explanation stating that the “.” operator is NOT needed when declaring or defining the method.

1 Like

How am I gonna have the same input as the solution and still be wrong when it came to step 2??? Had to replace my code with the “Solution” in order to get o the next step smh