Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Objects and variables from a different Class

 
rikstar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


[This message has been edited by Cindy Glass (edited September 07, 2001).]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
William Barnes
Ranch Hand
Posts: 993
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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:
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(){
 
Daniel Sie
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic