获取重载静态函数的地址[重复](Getting the address of an overloaded static function [duplicate])
可能重复:
如何指定指向重载函数的指针?我有一个库,其类定义为:
struct ClassA { static ClassA foo(long); static ClassA foo(double); }
我需要获取这两个函数的地址。 我正在尝试的代码给出错误C2440:无法从'overloaded-function'转换为'...'
ns::ClassA (ns::ClassA::*ClassA_foo1)(long) = &ns::ClassA::foo; ns::ClassA (ns::ClassA::*ClassA_foo2)(double) = &ns::ClassA::foo;
我认为它们可能是静态的,但在返回类型之前或之后放置静态会产生相同的错误。
Possible Duplicate:
how to specify a pointer to an overloaded function?I have a library which has a class defined as:
struct ClassA { static ClassA foo(long); static ClassA foo(double); }
I need to get the addresses of both of those functions. The code I am currently trying gives error C2440: cannot convert from 'overloaded-function' to '...'
ns::ClassA (ns::ClassA::*ClassA_foo1)(long) = &ns::ClassA::foo; ns::ClassA (ns::ClassA::*ClassA_foo2)(double) = &ns::ClassA::foo;
I thought it might be the fact that they are static, but placing static either before or after the return type gives the same error.
原文:https://stackoverflow.com/questions/12220452
最满意答案
这意味着该对象是您正在看到的名称类的实例化。 尝试在你的节点中运行这个:
class mySpecialClass { constructor() { this.myProp = 1; } } const myInstant = new mySpecialClass();
myInstant
mySpecialClass {myProp:1}
It means that the object is an instantiation of the class whose name you're seeing. Try running this in your node:
class mySpecialClass { constructor() { this.myProp = 1; } } const myInstant = new mySpecialClass();
myInstant
mySpecialClass { myProp: 1 }
相关问答
更多-
在我看来,基本的(基本的)对象文字和功能,即“私人”变量是有区别的。 由于对象不能实例化(因为它已经是Object一个实例),所以它不可能拥有自己的(新) 范围 。 它是高级JS编程的基本概念。 拥有一个新的范围允许你做几乎所有事情(你可以声明你自己的window , document或任何你想要的东西,除了你自己的范围内的JS 关键字 )。 现在举一些简单的例子: 假设您想要创建大量同一对象的实例(使用尽可能少的行): function MyObj(i) { var privateCounter ...
-
从回调内部访问对象字面值属性(异步方法)(Accessing object literal properties from inside callbacks (async methods))[2023-11-05]
您需要存储对this的引用,它指向contextStore对象; var contextStore = { 'root_id': undefined, 'setup': function() { var that = this; // Store reference here. chrome.bookmarks.getTree(function(tree) { that.root_id = computed_thing; // doe ... -
你可能会看到规模的影响:一个switch语句是O(n) ,而散列表查找(大概用于查找对象文字中的方法)是(摊销) O(1) 。 但是,大O措施只能准确地描述绩效如何超过真正的大投入。 在你的测试中,五条if语句比散列表查找更快也就不足为奇了。 所以基本上: 你会有多少把钥匙? 如果您只有五个密钥,那么您每次查询的平均查询次数会达到2.5次,而您显示的结果将比单个哈希表查找快。 但如果你有500个呢? 这是250条if语句的平均值 - 仍然是单个哈希查找。 哈希表(对象字面)方法在这一点上几乎肯定会更好。 但 ...
-
替换var lib = eval(code); 有: var lib = eval('(' + code + ')'); 当遗漏被忽略时,花括号被解释为代码块的标记。 因此, eval的返回值是fetchData函数,而不是包含该函数的对象。 当函数名称丢失时,块内的代码将被读取为带标签的匿名函数语句 ,该语句无效。 在添加了parens后,花括号被用作对象文本(如预期的那样),并且eval的返回值是一个对象,并带有fetchData方法。 然后,你的代码将工作。 Replace var lib = ev ...
-
这意味着该对象是您正在看到的名称类的实例化。 尝试在你的节点中运行这个: class mySpecialClass { constructor() { this.myProp = 1; } } const myInstant = new mySpecialClass(); myInstant mySpecialClass {myProp:1} It means that the object is an instantiation of the class whose name you'r ...
-
试试这个:因为你将哈希存储在一个数组中。 看来,我可能是错的,你想要访问阵列elem位置 - 1,每个产品ID。 如果你的ID是不同的,即.. 123,587,ABC987,那么以下内容将不起作用。 var ProductList = [ {"1": {Name: "Item name", Price: "0.99"}}, {"2": {Name: "Item name", Price: "0.99"}}, {"3": {Name: "Item name", Price: "8 ...
-
为什么在分配对象字面值之后不插入分号?(Why isn't a semi-colon inserted after this assignment of an object literal?)[2021-11-30]
在解析器视图中,当你不添加一个; ,解析器会将它看作: {}["one", "two"] 空对象的索引,不可用。 所以它在技术上是一个参考错误,因为它不存在或undefined 。 如此有效地解释为: undefined.forEach(...) In parser view, when you are not adding a ;, the parser will be looking at it as: {}["one", "two"] An empty object's index, which ... -
将其存储在变量中(或使用.bind或$.proxy ),因为在您的情况下, this指的是不是父对象的元素,如此 var allTabAnimation = { desktopClick: function() { var self = this; $('.allForms .investorOptions .investorOptions-wrapper .select-options input+label').click(function(e) { ...
-
user2 = { handle :"mytext", alertName: function(){ alert(handle);} }; user2.handle; //"mytext" user2.alertName() // gives error that handle is not defined in the console handle是object一个property ,所以你需要通 ...
-
对象字面值的属性隐式地有一个'any []'类型 - Angular 2(Object literal's property implicitly has an 'any[]' type - Angular 2)[2023-09-14]
随着新的打字稿更新出现了新的规则和标志。 其中一个标志是noImplicitAny标志。 这可以确保您不会像这样初始化变量: let avatars = []; 您可以更改您的tsconfig.json以便不再将其标记为错误: { noImplicitAny: false } 或者你可以创建一个接口/类来代表你的selectedContact export interface Contact { jcf: ContactDetail; meta: any[]; } 另一个界面: ...