Questions tagged [scope-resolution]
72 questions
3
votes
2 answers
Why does a locally scoped variable that hasn't been defined reference the instance variable of the same name?
I came across an odd bug in my code that revealed an interesting behavior of ruby. Hopefully someone can explain why it behaves this way.
I had a class with an instance variable @foo and a method that referenced a locally scoped variable foo. I…

solipsicle
- 864
- 1
- 9
- 19
3
votes
6 answers
Difference between . and :: in C++ for static members?
Possible Duplicate:
When do I use a dot, arrow, or double colon to refer to members of a class in C++?
When I try to access my static variable using Class.Variable I get the error that Error left of 'Variable' must have class/struct/union and…

Haris Hasan
- 29,856
- 10
- 92
- 122
3
votes
1 answer
Formally correct way to explicitly call destructor of typedef'd class type
This question is related to: C++: Explicitly call destructor of template parameter's typedef
I have the following:
class A {
public:
typedef std::shared_ptr Ptr;
…
};
Later on, I have a variable ptr of type A::Ptr * obtained via placement…

Alexander Klauer
- 957
- 11
- 18
3
votes
3 answers
Why is `::` called the 'scope resolution operator' when it doesn't act like an operator?
I can't think of a case when using :: to specify a scope would result in any code being generated. Every other operator I can think of actually (at least conceptually) generates code, it 'does something'.
So why is :: called the 'scope resolution…

Omnifarious
- 54,333
- 19
- 131
- 194
3
votes
1 answer
when do we use scope resolution operator before new ( ::new)?
I came across a code where scope resolution operator is placed before new. when do we use it. what is the meaning of it. Please anybody can explain ?

laksbv
- 629
- 5
- 6
3
votes
5 answers
Private Derived Destructor
When I am trying to delete the derived object polymorphically (that is: base class has public virtual destructor) why derived class private destructor is still being called? Why the scope resolution private is not working here.
class…

Sahib Yar
- 1,030
- 11
- 29
3
votes
1 answer
Pimpl, private class forward declaration, scope resolution operator
Consider these two classes that employ the Pimpl idiom:
ClassA: Pimpl class forward declaration and variable declaration on separate lines
ClassA.h:
#include
class ClassA {
public:
ClassA();
~ClassA();
void SetValue( int value…

Quokka
- 174
- 1
- 3
- 10
3
votes
1 answer
Dot or arrow operator vs. scope resolution operator for accessing base subobject
C++
Given a base class Base and a derived class Derived, the first thing constructed by Derived’s constructor is the Base subobject. Since it’s called a subobject, I assumed it can be accessed from client code like any other member object by using…

CodeBricks
- 1,771
- 3
- 17
- 37
3
votes
1 answer
Get Classname of Inherited Class when using Scope Resolution Operator (::)
Possible Duplicate:
Functionality of PHP get_class
For a small ORM-ish class-set, I have the following:
class Record {
//Implementation is simplified, details out of scope for this question.
static public function table() {
return…

berkes
- 26,996
- 27
- 115
- 206
2
votes
2 answers
c++ design question try catch
I have the following code in which dbh constructor may throw exception. The question I have is, dbh is declared inside try block. Will it be available after the catch? If yes, are there any other exceptions where the scope resolution is different…

Kiran
- 5,478
- 13
- 56
- 84
2
votes
1 answer
Scope Resolution Operator in SQL SERVER
What is the significance of using Scope Resolution Operator (::) in SQL SERVER. As we all know when we are using GRANT command Scope Resolution Operator will be part of syntax.
GRANT ALTER ON Schema :: DBO TO user_name
Is there any specific meaning…

Pரதீப்
- 91,748
- 19
- 131
- 172
2
votes
2 answers
Scope resolution operator for isalnum
I am asking this as a follow-up to this question. The previous question was asked almost three years ago, so I though asking a new one would be better.
The crux of that question I linked to is that the OP tried to run the following line of…

Konrad
- 2,207
- 4
- 20
- 31
2
votes
1 answer
Template argument after scope resolution operator is not substituted
I'm trying to make a generic code that will cause a compile error if B is not an ancestor of D. What I came up with:
template
struct assert_base_of {
enum {value = sizeof(B::D)};
}
It doesn't work. When I 'call' it like…

binduck
- 71
- 7
2
votes
5 answers
Different ways to access methods
I have seen that there are two different ways to access methods within a class. Are there any differences in behaviour, or are they purely alternative syntaxes for the same action?
$a = new A();
$a->foo();
A::foo();

Somk
- 11,869
- 32
- 97
- 143
2
votes
1 answer
Dependency injected or Scope Resolution Operator?
I didn't find a similar question, so I apologize if it already exists.
In my system I want a number of function libraries to ease a number of tasks across the whole system. That could be validating an e-mail. There's no reason to write the full…

Jens
- 1,302
- 1
- 13
- 20