首页 \ 问答 \ 获取重载静态函数的地址[重复](Getting the address of an overloaded static function [duplicate])

获取重载静态函数的地址[重复](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
更新时间:2023-12-03 22:12

最满意答案

这意味着该对象是您正在看到的名称类的实例化。 尝试在你的节点中运行这个:

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 ...
  • 您需要存储对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 ...
  • 在解析器视图中,当你不添加一个; ,解析器会将它看作: {}["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 ,所以你需要通 ...
  • 随着新的打字稿更新出现了新的规则和标志。 其中一个标志是noImplicitAny标志。 这可以确保您不会像这样初始化变量: let avatars = []; 您可以更改您的tsconfig.json以便不再将其标记为错误: { noImplicitAny: false } 或者你可以创建一个接口/类来代表你的selectedContact export interface Contact { jcf: ContactDetail; meta: any[]; } 另一个界面: ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)