问题标签 [static-functions]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
nosuchmethoderror - Guava 集中没有这样的方法异常
我在使用 Sets of guava 集合的静态方法时遇到以下异常,尽管该方法是静态导入的。可能是什么原因?这里使用的番石榴版本是12.0.1
.
c - 用大量静态函数组织 C 程序
我正在做一个个人项目,我只想公开 3 ou 4 功能。问题之一是我的 .c 文件越来越多的静态函数。目前它已经有 21 个静态函数。
组织包含大量静态函数的 .c 文件的最佳方法是什么?可以将这些静态函数分离到它们自己的 .c 文件中,然后将它们包含在主 .c 文件中吗?我更喜欢一种可以拥有单独文件的方法,以便从一个功能移动到另一个功能更简单(无需滚动只是在文件之间切换)。
谢谢
编辑
为了更好地理解问题,这里直接链接到我在管理静态函数时遇到困难的 .c 文件:
https://github.com/AntonioCS/mustache/blob/master/src/mustache.c
php - PHP 私有静态函数
我是一名初级 PHP 程序员。我还有很多东西要学。这就是我问这个问题的原因。在一个类中,您有一个公共函数,您可以从该类外部调用它。有时您有一个私有函数,您可以在私有函数所在的类中多次调用它,以实现可重用的目的。我喜欢将私有函数设置为静态,并使用以下命令调用该函数:
通过使用self它提醒我这个私有函数驻留在那个类中。如果我将$this->privateFunctionName()用于非静态函数,它可能位于超类/基类或该子类本身中。这就是我喜欢使用静态私有函数的原因。从专业的角度来看,使用静态私有函数而不是非静态是一个好主意吗?像您这样的专业程序员更喜欢避免使用静态函数有什么缺点吗?
c++ - 在已删除对象上调用静态函数
我会开始学习 C++,但我不明白这是内存泄漏还是某种巫术?!
我有一些“单例”类(仅用于演示):
这些的输出是:
所以我的问题是:为什么在调用析构函数后,静态变量中仍然有类 S 的工作副本?
更新:感谢您的回答。我意识到我的错误。请原谅我的打扰。
php - 在一个类中混合静态和非静态方法是否可以接受?
我有一个相对简单的问题,虽然谷歌上有很多关于它的帖子,但我找不到一个简单回答这个问题的帖子。
所以简短的问题是“在一个类中混合静态和非静态方法是否可以接受?”。我想我真的在问“坚持使用一种方法是一种好习惯”,还是“同时使用这两种方法时有什么要考虑的事情”。
例如,如果我正在创建一个类来处理冰箱里的食物,那么以下哪个(或其他)是最好的方法
示例 1:
或示例 2:
提前致谢
x86 - 为什么静态函数有时会有非标准堆栈帧?
在 wikibookx86 Disassembly
中,写到有时存在不设置标准堆栈帧的子例程。一种这样的情况是当我们在 C 中声明一个静态函数时。以下几行已经写在书中。
When an optimizing compiler sees a static function that is only referenced by calls (no references through function pointers), it "knows" that external functions cannot possibly interface with the static function (the compiler controls all access to the function), so the compiler doesn't bother making it standard
.
我对上述陈述有以下疑问:
- 外部函数是否可以使用函数指针引用静态函数?如果是,如何?为什么允许?(我问这个是因为据我所知,静态函数具有本地范围,并且不能被任何外部函数访问)?
- 非标准堆栈帧是什么意思?非标准堆栈帧与标准堆栈帧有何不同?欢迎使用汇编代码进行解释:)
编辑:另一个我想回答的问题:为什么上述情况下的编译器设置非标准堆栈框架而不是标准堆栈框架?
c++ - How static member function can call the static private data member ? what kind of the internal transformation is needed?
Just imagine we have the following class:
In the code above, we have class which contains one private, static member variable which called into our public, static member function get_sum(). Now the question: How the function which has not "this" pointer can access class member variable m_a ? In the Lipman's book I have read that:
(( Point3d* ) 0 )->object_count();
where
object_count()
does nothing more than return the_object_count
static data member. How did this idiom evolve ? ..............................
..............................
//internal transformation of call
object_count(( Point3d* ) 0 );
The language solution was the introduction of static member functions within the official cfront Release 2.0. The primary characteristic of a static member function is that it is without a
this
pointer.
I don't understand how we can cast 0 to class type object ?
php - 在 PHP 中,在函数名前添加“&”是什么意思?
我正在使用用 PHP 编写的 CMS 包。在其中一个核心文件中,我看到了用于在类主体中定义函数的以下行。
我不明白为什么函数名“getLib”前面带有 & 符号?我以前从未见过这样的事情。
有人可以详细解释一下为什么会这样做,以及它比简单地使用函数名有什么好处?
php - 我可以动态创建一个类名,然后用它在 PHP 中调用该类的静态函数吗?
我有两个具有相同静态方法的类,但每个类都有不同的方法实现。在我的代码中,我知道我需要调用哪个静态方法,但类类型是动态确定的。像这样的东西:
我正在尝试以这种方式使用:
但它不起作用。我可以动态创建一个类名,然后用它来调用该类的静态函数吗?
c++ - How to calculate user input using non-static functions
My testing environment: Visual Studio 2010 Ultimate.
the error I received:
main.cpp(39): error C2352: 'Account::DepositAmt' : illegal call of non-static member function
I've tried changing it to static functions but it only caused more errors.
account.cpp (23): error C2597: illegal reference to non-static member 'Account::balance' account.cpp(40): error C3867: 'Account::balance': function call missing argument list; use '&Account::balance' to create a pointer to member
I've tried to fix using the suggestions of trying to reference but failed miserably.
the objective, to be able to take the user input for the initial balance, and then if the user is making a deposit add it to the balance, if a user makes a withdrawal, subtract it, then print final balance. I am required to create member functions
All I want is to figure out how to achieve this without having to change to static functions (if at all possible).
This is my code for the
Account.h
Account.cpp
Main.cpp