Questions tagged [scope-resolution]
72 questions
0
votes
2 answers
PHP - Using a Double colon with a class varible
I'm trying to call a static function with a varible name from a class.
The desired outcome:
class Controller extends Controller {
public $model = 'ModelName';
public function index() {
$woot = $this->model::find('');
…

Yossi
- 1,056
- 2
- 13
- 22
0
votes
2 answers
Declaring class as integer
class test {
public:
static int n;
test () { n++; };
~test () { n--; };
};
int test::n=0; //<----what is this step called? how can a class be declared as an integer?
int main () {
test a;
test b[5]; // I'm not sure what is…

M. A. Khan
- 9
- 1
0
votes
1 answer
Call to a non static method with out creating an object works fine in PHP
I am doing a PHP tutorial and I found this code
Class Insurance
{
function clsName()
{
echo get_class($this)."\n";
}
}
$cl = new Insurance();
$cl->clsName();
Insurance::clsName();
here function clsName() is accessed without…

Kanishka Panamaldeniya
- 17,302
- 31
- 123
- 193
0
votes
1 answer
How to use overloaded function operator (operator()) of another class?
This is the class that contains the overloaded function operator:
template < typename KeyType=int >
class Less {
public:
bool operator()(const KeyType &a, const KeyType &b) const { return a < b; }
};
How can I use this? This class is…

Bobazonski
- 1,515
- 5
- 26
- 43
0
votes
1 answer
Ampersand before a scope resolution operator in php
Hello I am here to ask you a question about php. I had searched many times on web to get a solution, but I haven't found it yet. I have seen a code like this:
$mail_object =& Mail::factory("smtp", $smtpinfo);
$mail_result =…

SAarah
- 3
- 2
0
votes
1 answer
Scope Resolution to a Static Function or a Pointer in Template Class
I'm currently working on some code that someone else has written and I'm unsure of the efficiency of their method. They have a template class that uses scope resolution to access the class's members instead of having a pointer to the templatised…

Edward
- 235
- 4
- 18
0
votes
2 answers
Why is scope resolution not working on overridden variable?
When I looked at the following code sample, I thought d.B::num was the same as b.num but it isn't. It appears to be a different variable that has its own address. When I click on the run button, I see each of the three variables b.num, d.num and…

Mo Sanei
- 445
- 6
- 22
0
votes
1 answer
rails 3 using folder name as namspace throws uninitialized constant error
I'm trying to upgrade an app from rails 2.3 to 3.0 and it has a file
app/utility/interface/import/import_statistics_manager.rb
which contains
class Utility::Interface::Import::ImportStatisticsManager
//code here
end
I beleive…

Siva
- 7,780
- 6
- 47
- 54
-1
votes
4 answers
How to access a header member type without scope resolution operator in C++?
I am learning C++, this may be a silly question.
I want to create a class for common type definitons and using it in many cpp files by inluding.
Header is "CommonTypesCls.h":
class CommonTypesCls
{
public:
typedef unsigned int UINT32;
…
user5090127
-2
votes
2 answers
C++- "using" keyword or using namespace name with scope resolution operator
various programs in C++ are written without using scope resolution operator in this way:
#include
#include
int main()
{
std::string name = "My Name";
std::cout << name << std::endl;
return 0;
}
and I have also seen using…

Prothom Ontim
- 11
- 1
-2
votes
3 answers
Why doesn't C++ allow const after ::?
Folks,
Problem Statement - Does C++ allow a (static) const be limited to a class scope, so I can get rid of #defines that pollute entire namespace?
My observation is NO (in the following DIFFERENT examples), and I'd like to find out why and what's…

user2574529
- 51
- 2
-8
votes
2 answers
Error with resolution operator while referencing model type depending on dynamic variable (PHP 5.2)
Background Information:
I am trying to simplify the structure of my Yii app, by moving a common function from child classes into the base class they are extending from.
I moved the loadModel($id) function from the User (child) controller into the…

Samuel Liew
- 76,741
- 107
- 159
- 260