Buckys C++ Programming Tutorials - 13 - Using Variables in Classes

thenewboston · 1.1M views · 2011 · 9:12

Open on YouTube

C, C++, Rust, Go & systems languagesEducation & learningtutorial

Why Stack Overflow recommends it

Stack Overflow users link it when they are following the thenewboston C++ series and get stuck on class variables, setters and getters, or private versus public members.

Recommended by 2 people across 2 different months, 2012 to 2014.

What it is

A short beginner C++ tutorial from Bucky Roberts of thenewboston, lesson 13 in his series. It shows how to declare variables inside a class and use public member functions to set and get a private name value.

What people said

Recommends user1433958 · 2012-09 · Stack Overflow · on “setting variable from another class”

I watched this tutorial [this video] and I can get the code to output a string easy, but I want the user to be able to set their own name and save it. Sorry I'm really new to c++ so any help would be greatly appreciated thank you.

Recommends Dave Martinez · 2014-05 · Stack Overflow · on “cin to set string of variable 'name' in OneClass”

I am not sure how to use it properly yet, I am just following NewBoston's C++ tutorial [this video] , lesson 13 to be exact.

Cites Jim Jam · 2013-12 · Stack Overflow · on “How do you access private variables using public functions?”

So I don't know if you any of you have been/goes on the NewBoston.Com (great resource by the way), but I was watching this video and the teacher was saying how you can access private info using public functions... This is the video: [this video] And of course, just skip to the end to get to the gist of it. The thing I don't get though, is how can you access private information using a public function. If you make a function that's public that allows anyone to set the name, and get that name, then isn't it just public anyway?, Wouldn't anyone be able to mess my code and my desired output?