车b();解释此语句在执行时将执行的操作 [英] Car b(); Explain this statement what it would be done in the time of execution
本文介绍了车b();解释此语句在执行时将执行的操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Car
{
public:
Car(){}
};
int main()
{
Car b();
}
车是一类
然后我们写"Car b();"请告诉我此语句的意思是
Car is one class
Then we write "Car b();" Please tell me this statement means
推荐答案
这意味着您实例化(创建)一个名为b
的对象,该对象的类型为Car
.这是基本的C ++,您可以在此处 [ ^ ]或您当地书店或图书馆的书中
不好意思,我没想清楚.该表达式试图定义一个名为b
的函数,该函数返回类型为Car
的对象.实例化Car
对象的正确方法是使用以下形式的语句:
It means you instantiate (create) an object calledb
of typeCar
. This is basic C++, and you can find some good information about classes and objects here[^] or in books from your local bookshop or library.
Apologies, I was not thinking straight. That expression is trying to define a function calledb
, which returns an object of typeCar
. The correct way to instantiate aCar
object is by a statement of the form:
Car b;
// or to create an object on the heap
Car* pb = new Car();
与Richard相反,我认为b不是对象而是函数.我的解释基于本周第一名草药销售商 [
Contrary to Richard I believe b is not an object but a function. My interpretation is based on Herb Sutters Guru Of The Week #1[^]
这篇关于车b();解释此语句在执行时将执行的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文