重载的构造函数和继承 [英] overloaded constructors and inheritence

查看:79
本文介绍了重载的构造函数和继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有...

suppose i have...

展开 | 选择 | Wrap | 行号

推荐答案

使用strncpy()不是strcpy()。这将导致你的格雷夫。


你只能在创建时调用构造函数。进入正文后,它已被调用。你给出的第二个例子是Javaism。不能用C ++做。


Adrian
Use strncpy() not strcpy(). It will cause you greif.

You can only invoke the constructor at creation. Once you have entered the body, it has already been invoked. The second example you gave is a Javaism. Can''t do that in C++.


Adrian



使用strncpy()不是strcpy()。这将导致你的格雷夫。


你只能在创建时调用构造函数。进入正文后,它已被调用。你给出的第二个例子是Javaism。不能用C ++做。


Adrian
Use strncpy() not strcpy(). It will cause you greif.

You can only invoke the constructor at creation. Once you have entered the body, it has already been invoked. The second example you gave is a Javaism. Can''t do that in C++.


Adrian



这就是我所要求的为什么不 ....为什么第二个例子不像第一个例子那样....

thats what i am asking why not....why the second example is not working just like the first....



那是什么我问为什么不 ....为什么第二个例子不像第一个例子那样工作....
thats what i am asking why not....why the second example is not working just like the first....



因为C ++定义就这样。 ;)


Adrian

Because C++ defines it that way. ;)


Adrian


这篇关于重载的构造函数和继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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