GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 05-Jun-2007, 08:54
ultimateguy ultimateguy is offline
New Member
 
Join Date: Jun 2007
Posts: 2
ultimateguy is on a distinguished road

Changing scope of object


I have two classes, call them class1 and class2. In my main(), I declare a new class object:

class2 stepping_action = new class2;

stepping_action has a variable called "contained" that is a boolean.

What I need to do is change the value of this variable from within class1. When I try, it tells me that stepping_action is not in the right scope. I have tried declaring stepping_action outside of the main but I still get the same error.

How can I change this variable from class1?
  #2  
Old 05-Jun-2007, 09:10
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,217
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Changing scope of object


Quote:
Originally Posted by ultimateguy
I have two classes, call them class1 and class2. In my main(), I declare a new class object:

class2 stepping_action = new class2;
That will not compile. How about showing us what you are really working on?

Quote:
Originally Posted by ultimateguy
When I try, it tells me...
How about showing us what you tried? Show class definitions and show the code that tries to do the deed.

In other words: Show Us the Code!

Regards,

Dave
  #3  
Old 05-Jun-2007, 12:35
ultimateguy ultimateguy is offline
New Member
 
Join Date: Jun 2007
Posts: 2
ultimateguy is on a distinguished road

Re: Changing scope of object


I fixed the problem.
  #4  
Old 05-Jun-2007, 12:43
coolprogrammer coolprogrammer is offline
New Member
 
Join Date: Jun 2007
Posts: 3
coolprogrammer is on a distinguished road

Re: Changing scope of object


No need of showing code is required....
do the following:--
Make class1 as a friend of class2 !!!
(or)
Make the function in which you want to change the value of "contained"
make that as friend!!!
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
constructors/classes mapes479 C++ Forum 3 19-Nov-2006 18:34
Use of HttpWebRequest object dattaforit .NET Forum 1 08-Oct-2006 06:29
Please Help Me To Build My Calendar!!! suriacute85 Java Forum 0 05-Oct-2006 20:39
Pointer values changing unexpectedly spudtheimpaler C Programming Language 11 04-Mar-2004 17:37

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 10:16.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.