So?
You're struggling with fundamentals.
Get a solid few months experience of basic C++ before you start worrying about the latest toys in C11/14/17/20/23.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
But I have been doing cpp for two years! And all studies show all takes to become good at something takes 30 hours of time spent on it.
Plus, I am confused with the order and why it isn't working when I believe I read it right...a simple problem I can do. Something more advanced? Probably struggle...
> But I have been doing cpp for two years!
Based on how you couldn't figure out you needed member variables when the error messages told you as much, I doubt it.
Looking at your post history, it looks like you dabble every couple of months and then forget everything.
And most of them are the same basic question.
> And all studies show all takes to become good at something takes 30 hours of time spent on it.
Try 10,000 hours.
OK, 10,000 hours is bunk, but competence isn't achieved in a week.
30 hours of C++ is enough to tell the difference between a C++ program and a hole in the ground.
Like I said, your current book is crippling your ability to think.
You're just mindlessly copying the text, but you don't know "why" things are the way they are, and you're at a complete loss when it doesn't work.
Given a problem statement like this:
"Create a class called Dog with attributes age, weight and color. Add suitable set/get methods".
You should be able to produce that class without resorting to looking at pretty cartoon pictures.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
But which step says to remove the member variables? Note that you were already asked about that in post #13.
Here's what I get when I follow the steps letter-by-letter (I didn't implement main since some of the steps were cut off). This code compiles without warnings (even with the -Wall -Wextra -Wpedantic compiler flags):
Code:// step 1 #include <string> #include <iostream> using namespace std; // step 2 class Dog { // step 3 private: int age, weight; string color; // step 4 public: // step 5 void bark() { cout << "WOOF!" <<endl; } // step 6 // void setAge(int yrs) { age = yrs; } // void setWeight(int lbs) { weight = lbs; } // void setColor(string hue) { color = hue; } // multiple step 2 (replace the three setter methods (above) with a single combined setter prototype) void setValues(int, int, string); // step 7 int getAge() { return age; } int getWeight() { return weight; } string getColor() { return color; } }; // multiple step 3 void Dog::setValues(int age, int weight, string color) { // multiple step 4 this->age = age; this->weight = weight; this->color = color; }