通过deafult调用参数化的构造函数。 [英] Calling parametrized contructor by deafult.

查看:61
本文介绍了通过deafult调用参数化的构造函数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







我有A级带2个构造函数

as

默认

Hi,


I have a class A with 2 constructor
as
Default

public A()
{}






and

public A(int a,int b)
{}



< br $>








我想每次创建时都调用第一个参数化构造函数一个对象然后默认。



如何将参数化构造函数设置为默认值。





谢谢







I want to call first parametrized constructor every time i create an object then default.

How to make parametrized constructor as default.


Thanks

推荐答案

试试这个:

Try this:
public A()
    : this(0, 0)
{
}
public A(int a, int b)
{
    // your code here
}



更改 0 进入你需要的整数。


这篇关于通过deafult调用参数化的构造函数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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