Questions tagged [scope-resolution]
72 questions
1
vote
2 answers
Why doesn't scope-resolution work here?
What is the reason why the function bar() can't be overloaded here?
namespace foo
{
void bar(int) { }
struct baz
{
static void bar()
{
// error C2660: 'foo::baz::bar' : function does not take 1 arguments
…

user541686
- 205,094
- 128
- 528
- 886
1
vote
2 answers
c++ - iterating through a map of 3 elements
I'm very new to the use of STL containers in C++.
I have a map of 3 elements (2 strings as a pair - acting as the key, and an int acting as the value.)
map, int> wordpairs;
But when I try to iterate through it like this:
for…

RockAndaHardPlace
- 417
- 1
- 7
- 18
1
vote
1 answer
struct with member function as parameter
I am a beginner in C++ and stack exchange. I am working on an Interface class that gets keyboard input and checks to see whether it is correct through looping through an array of structs which contains strings to compare to and strings to output…

GratefulOne
- 23
- 1
- 5
1
vote
1 answer
Is there any difference between qualified ::toplevel_namespace and unqualified toplevel_namespace?
Generally, the difference between ::any_name and any_name should be clear. If preceded by :: the name is always and only looked up in the global namespace.
I was wondering however whether there is an technical(*) difference, given a namespace that I…

Martin Ba
- 37,187
- 33
- 183
- 337
1
vote
3 answers
C++ Enumerations: Assign a variable or use scope resolution?
I'm compiling this C++ code with Visual Studio 2012. I noticed that I could use enumeration values without a scope resolution operator (::).
Here's the important parts of my code outside of int main():
enum SortMethod
{
BY_NAME,
…

lfitz
- 35
- 5
0
votes
2 answers
PHP: Scope Resolution Operator & Overloading perfomance
I have 2 questions:
1) Is the Scope Resolution Operator (::) slow for static access (or slower than -> for an instantiated class)?
The name kinda suggests it has to "resolve" a scope so that's why I'm asking.
2) What about overloads, specifically…

thwd
- 23,956
- 8
- 74
- 108
0
votes
1 answer
PHP: calling non-static methods with scope resolution operator
Possible Duplicates:
Calling non static method with "::"
Does static method in PHP have any difference with non-static method?
What is the reason for allowing calling non-static methods using ::, given we don't try to access anything inside the…

Dan
- 11
- 5
0
votes
2 answers
PHP: How to create function which will be accessible with :: (double colon, scope resolution) in another classes
I´m trying to create a logging class which will be accessible in all Classes around the PHP app by
logger::log(something);
and this will add next row into my logfile (the part with inserting into file is easy for me). I saw the double colon in DIBI…

neologyc
- 3
- 4
0
votes
1 answer
How to access function scope variables in c++?
Global scoped variables can be accessed within a function using the :: operator. Since global scopes dont have a name, the left of :: could be empty. How will I access a variable defined in a function scope which is later overridden in a block…

mman
- 89
- 3
0
votes
0 answers
Can the scope resolution operator be used in the definition of a member function when the member function is defined outside of its class definition?
Can the scope resolution operator be used in the definition of a member function when the member function is defined outside of its class definition? Like this:
class Myclass{
private:
void foo();
public:
void foo2();
};
void…

Marcus Kim
- 283
- 2
- 12
0
votes
1 answer
C++ Binary Scope Resolution Operator and Classes
Is there a way to use "block" class scope resolution in C++ so that I don't have to write the same boilerplate code for every function in my class' implementation file.
I find it extremely repetitive to write the same class name and binary scope…

Paul Solt
- 8,375
- 5
- 41
- 46
0
votes
2 answers
not declare in scope when compiled g++
This is my A.h file
class A
{
public:
void menuChoice();
void displaystartingMenu(); //EDIT
};
This is my A.cpp file
#include "A.h"
void displaystartingMenu()
{
cout<<"Please enter your choice:";
}
void A::menuChoice()
{
…

what
- 373
- 2
- 10
- 20
0
votes
1 answer
Applying scope resolution operator causes compiler to choke
I'm using SDL's RenderCopy function:
SDL_RenderCopy(Game::mRenderer, Game::mTexture, &mSourceRect, &mDestinationRect);
The final two arguments are the source and destination rect to copy an image to and from, it is expecting a pointer to the rects,…

Trevor Hart
- 993
- 7
- 26
0
votes
2 answers
How to write the scope resolution operator function header for nested classes?
Hey I have a fairly simple question that some quick google searches couldnt solve so I'm coming here for some help.
I'm having trouble just getting my assignment off the ground because I can't even write the skeleton code!
Basically I have a header…

Tyler Kelly
- 564
- 5
- 23
0
votes
1 answer
PHP - call to a variable static method using the scope resolution operator
I would like to call to a static method in such a way that class name and method name are variables.
Example:
class QQQ {
public function www($x) {
echo $x;
}
}
$q = 'QQQ';
$w = 'www';
$q::$w(7); // this is what I am trying to do but…

daryqsyro
- 157
- 2
- 9