Solved

Very very easy question

Posted on 2000-05-17
6
171 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

708 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

17 Experts available now in Live!

Get 1:1 Help Now