?
Solved

Very very easy question

Posted on 2000-05-17
6
Medium Priority
?
177 Views
Last Modified: 2010-04-02
If I have object bigcookie
class cookie{
public:
int chocolatechips;
};
cookie bigcookie;

and a function in a namespace:
namespace foodfuncs{
void bigcookie(void){}
}

If I say 'using foodfuncs' bigcookie thenceforth refers to foodfuncs::bigcookie.

How do I make it refer to the cookie object again? Am I right in thinking it is a compile-time issue, and in the executable, these two entities will have different names?

Thank you
0
Comment
Question by:glebspy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Expert Comment

by:forza
ID: 2818589
>How do I make it refer to the cookie object again?
What do you mean by "again"?
You cannot have the bigcookie func refer to the object. Why would you do that?
0
 
LVL 1

Author Comment

by:glebspy
ID: 2818614
ok I have the above followed by:

void main(void);
cookie bigcookie;
bigcookie.chocolatechips=1;

//Now I use the namespace
using foodfuncs:
bigcookie();

//ok so far so good but now I want to
//be able to say
bigcookie.chocolatechips=3;
//which I can't because thanks to my //using statement bigcookie means
//the function bigcookie

So now I hope you understand the question
thank you
0
 
LVL 1

Author Comment

by:glebspy
ID: 2818624
ok I have the above followed by:

void main(void);
cookie bigcookie;
bigcookie.chocolatechips=1;

//Now I use the namespace
using foodfuncs:
bigcookie();

//ok so far so good but now I want to
//be able to say
bigcookie.chocolatechips=3;
//which I can't because thanks to my //using statement bigcookie means
//the function bigcookie

So now I hope you understand the question
thank you
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Accepted Solution

by:
nietod earned 10 total points
ID: 2818974
Try

::bigcookie.chocolatechips=3;

0
 
LVL 1

Author Comment

by:glebspy
ID: 2819064
I really wanted to know how to reverse the effect of the 'using' statement for good, rather than just that one instance - still I guess its worth 5 points
0
 
LVL 22

Expert Comment

by:nietod
ID: 2819250
>> I really wanted to know how to reverse
>> the effect of the 'using' statement for good
Then you should have asked that.

And you should not have given a bad grade for an answer that was correct, but just not what you wanted--especially since I didn't answer. I would much much rather have not had the points than have a bad grade in my record.

I believe that a using declaration obeys scope rules.  So use it inside a scope and it will not extend outside of that scope.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question