Howdy! I'm a long time lurker and a 1st time poster trying to learn C++ on his own.
I made a really standard "99 bottles" program, featuring Jay Z!
So I made a JayZ class, and it has a function that counts until 99 problems, and it works great!
Then I wanted to challenge myself, so I made a KanyeWest class that's supposed to get the value of the problems value(in the JayZ Class) and print it to the screen.
The problem is, KanyeWest.imGoingToLetYouFinish() only gives the value of the variable as it was declared, and not the 99 value I expected.
So I guess I'm asking two questions.
1. Why does the KanyeWest class only get the initial value of the problems variable?
2. What's the "Proper" way to have a class get variable values from another class?
That sounds like a really good idea! There's one problem though, I don't know how to do that syntactically. Where in my code would I do that? Can you show me?
P.S. I really really appreciate the help, I'm getting close to actually being able to do the things I want to do in C++ and this is really helping.
You'll need to redefine your function to take a parameter of the correct type. Then when you call the function you'll need to pass the correct variable.
I don't mean to sound dumb, because I think you and the tutorial firedraco pointed out answered my question; but I'm still stumped.
"redefine your function to take a parameter of the correct type. Then when you call the function you'll need to pass the correct variable." Sounds like it makes sense. I just haven't the faintest idea of how to do that. I barely know what that means.
I'm going to dig through the class tutorial on the website, but if anyone one want's to copy pasta the code that does what jlib's saying, It'd help me understand this whole thing ALOT more.
Thanks for teaching me, sorry I'm a sucky student.
Edit 5/18/2015, I learned a lot more about constructors and class inheritance, jib more than answered my question.