Solved

Very very easy question

Posted on 2000-05-17
6
172 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Accepted Solution

by:
nietod earned 5 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Getting IP address 8 71
Grammars for C C++ and java 1 114
I could not build boost code, 10 78
How do I save this device context as a .bmp or a picture of some kind? 2 47
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 …
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now