对象实例化在c ++中 [英] object instantiation in c++

查看:142
本文介绍了对象实例化在c ++中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++中,如果你实例化一个类的对象,那么对于每个
对象,类的所有方法都会被复制到新对象中。

In C++ is it true that if you instantiate an object of a class, that for every object all of methods of the class are copied for the new object?

我试图指向一个具有两个不同对象的类的方法,但是我会遇到
的问题,它带有指向成员的指针。

I tried to point to a method of a class with two different objects, but I'd problems with pointer to member.

任何想法?

推荐答案


在C ++中是真的,如果你实例化一个类的对象,对于每个对象的类的所有方法都复制为新的对象?

In C++ is it true that if you instantiate an object of a class, that for every object all of methods of the class are copied for the new object?

不,成员函数通常不会复制到任何地方。不同的隐式参数这个被传递给任何非静态成员函数,对于该类型的每个对象。

No, member functions are not usually copied anywhere. A different implicit parameter this is instead passed to any non-static member function, for each object of that class-type.

这篇关于对象实例化在c ++中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆