车b();解释此语句在执行时将执行的操作 [英] Car b(); Explain this statement what it would be done in the time of execution

查看:77
本文介绍了车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 called b of type Car. 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 called b, which returns an object of type Car. The correct way to instantiate a Car 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屋!

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