Using Objects and variables from a different Class
rikstar
Greenhorn
Joined: Sep 02, 2001
Posts: 6
posted
0
I would like to know how to call a Vector Object in one method of my Class to another method in another Class. Did u get that? Okay here it is, I have a Class called "MyVector", in there I have a method called PopVector(), where I have created a Vector Object called "sentence". What i now need is to be able to call the vector "sentence" into my second class "MyVector2" and then into a method called OptionsPromt() within that class. Complex?? I think so! Can it be done and how? Cheers.
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
[This message has been edited by Cindy Glass (edited September 07, 2001).]
"JavaRanch, where the deer and the Certified play" - David O'Meara
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
rikstar (again) Please change your name to be compliant with JavaRanch's naming policy. Your ID should be 2 separate names with more than 1 letter each. We really want this to be a professional forum and would prefer that you use your REAL name. Thanks, Cindy
Joseph Russell
Ranch Hand
Joined: Jan 08, 2001
Posts: 290
posted
0
Cindy, I don't understand your explanation. How would MyVector2's OptionsPrompt() has access to MyVector's PopVector()? When you defined OptionsPrompt(), did you actually mean: void OptionsPrompt(0) { //something something } and what does the (0) means? Thanks
How would MyVector2's OptionsPrompt() has access to MyVector's PopVector()?
MyVector2 has a local variable, called mv, which is an instance of MyVector. So any method or variable (not defined protected or private) of MyVector will be accessable. In this case you would get to it by saying something like:
Please ignore post, I have no idea what I am talking about.
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
Sorry I typoed on the original post. I didn't get the shift key down and typed a 0 instead of a ). void OptionsPrompt(0{ should be void OptionsPrompt(){