Solved

Very very easy question

Posted on 2000-05-17
6
173 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.

770 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