Questions tagged [scope-resolution]
72 questions
7
votes
1 answer
Multiple paamayim nekudotayims in PHP, why not?
In PHP 5.3.6, I've noticed that the following won't work:
class Foo{
public static $class = 'Bar';
}
class Bar{
public static function sayHello(){
echo 'Hello World';
}
}
Foo::$class::sayHello();
Issuing an unexpected…

Dan Lugg
- 20,192
- 19
- 110
- 174
7
votes
2 answers
Scope-resolution operator :: versus member-access operator . in C#
In C#, what's the difference between A::B and A.B? The only difference I've noticed is that only :: can be used with global, but other than that, what's the difference? Why do they both exist?

user541686
- 205,094
- 128
- 528
- 886
7
votes
3 answers
how to call parent class method in php
This is the working code, but i want to know without using another object(commented $foo) how could i use printItem() method of class Foo using the $bar object. New to oop programming concept so may be a weak thing to ask but really unable to locate…

Trialcoder
- 5,816
- 9
- 44
- 66
6
votes
2 answers
Scope resolution in templated inheritance (possibly what is called mixin)
Suppose I have the templated classes
#include
class A1 {
public:
int x{314159};
};
template
class A2 : public Context {};
template
class A3 : public Context {};
template
class A4…

user647486
- 187
- 5
6
votes
1 answer
How to call function with same name as class member
How can I call non-member function listen() (included from sys/socket.h) from a class which defines a member function with the same name listen()?
#include
void Socket::listen(int port)
{
...
listen(sock_fd, 10); // this…

Martin Heralecký
- 5,649
- 3
- 27
- 65
6
votes
7 answers
Is there a scope resolution operator in C language?
I am reading a book on the C language ('Mastering C'), and found the topic on scope resolution operator (::) on page 203, on Google Books here.
But when I run the following code sample (copied from the book), the C compiler gives me an error. I…

munjal007
- 245
- 1
- 2
- 6
6
votes
4 answers
Can the :: operator appear in the context different from scope resolution in qualified name lookup?
As known scope resolution operator used for the purposes of qualified name lookup. But what is the value returned by ::? As I understood it is postfix unary operator. Consider the following:
namespace A
{
//something
}
A:: //error: expected…
user2953119
6
votes
4 answers
Javascript equivalent of PHP's :: (Scope Resolution Operator)
In PHP, you can do something like that:
class myClass() {
function doSomething(someVar) {
// do something here
}
// etc... (other methods and properties)
}
Then, of course, you could call that method after instanciating the…

Rolf
- 5,550
- 5
- 41
- 61
6
votes
5 answers
C# Default scope resolution
I have inherited a c# class 'Button' (which I can't change) which clashes with the BCL class 'Windows.Forms.Button'. Normally, Id be very happy to go:
MyPackage.MyClass.Button;
But there are a large number or references to this class which is a…

TK.
- 46,577
- 46
- 119
- 147
5
votes
6 answers
Call private method from inherited class
I want to implement a hook-system in my simple ORM, in PHP:
class Record {
public function save() {
if (method_exists($this,"before_save")) {
$this->before_save();
}
//...Storing record etc.
}
}
class Payment extends Record {
…

berkes
- 26,996
- 27
- 115
- 206
5
votes
4 answers
what does the scope resolution operator used in a class name mean
I came across this code.
class SomeClass::OtherClass : public BaseClass
{
// stuff in here
}
SomeClass is a class, so maybe OtherClass is a class that exists inside the scope of SomeClass? I've just never seen it done this way.
So, is that what…

Chris Morris
- 4,335
- 4
- 24
- 28
4
votes
1 answer
Unable to initialize new List as value of a Map with the :: Operator?
While working on a card game project, I was trying to create a new Map while already having a List I wanted to use as a KeySet. The Map has to use Keys of type Player and have each of them hold a Value consisting of a single List, with Player…

alistairv
- 159
- 9
4
votes
1 answer
Using variable with Scope Resolution Operator in PHP
I am having a situation where, I have to use static method but here my class name is stored in some variable.
As per this link: http://php.net/manual/en/keyword.paamayim-nekudotayim.php#50310 I can not use variable with ::.
for reference my code…

Avinash
- 6,064
- 15
- 62
- 95
4
votes
2 answers
C++ "::" without class name
I came across the following code structure in C++:
uint32_t AClass::Action(....)
{
..
status = ::Action(...);
..
}
I am not sure what ::Action() means. Which class does it belongs to? NOTE: the argument list of ::Action(...) is different from…

drdot
- 3,215
- 9
- 46
- 81
4
votes
2 answers
Friends, operator keyword and scope resolution
namespace GameForge
{
namespace Core
{
class CTribool;
}
}
GameForge::Core::CTribool operator ! ( const GameForge::Core::CTribool& rkTribool );
namespace GameForge
{
namespace Core
{
class CTribool
{
…

Adrian Goudard
- 115
- 1
- 9