'class'关键字在C ++中的变量定义 [英] 'class' keyword in variable definition in C++

查看:341
本文介绍了'class'关键字在C ++中的变量定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在任何人问之前,是的,这是家庭作业的一部分,是的,我在问之前做了很多Google搜索。我花了最后一个小时在许多不同的关键字上搜索,但是找不到任何东西。

Before anyone asks, yes, this is part of a homework, and yes, I did a lot of Googling before asking. I spent the last hour searching intensively on Google with many, many different keywords, but just could not find anything.

这里是问题:


下面的变量定义是什么意思: class MyClass * myClass;

我尝试过类似 class MyClass * myClass = new MyClass(); 的代码,简单地创建一个指向 MyClass

I tried that code with something like class MyClass* myClass = new MyClass(); and found that it simply creates a pointer to a new instance of MyClass.

所以,使用 class 前缀?它有什么区别吗?

So, what's the advantage of using the class prefix? Does it make any difference?

有人有一个链接到一些资源吗?我根本找不到任何东西(真的,真的很难找到除了类定义!)。

Does someone have a link to some resources about it? I simply could not find anything (it's really, really hard to find things other than "class definition"!).

非常感谢!

推荐答案

精心设计的类型说明符是一个以类,struct,enum或union关键字开头的类型名称。

An elaborated type specifier is a type name preceded by either the class, struct, enum, or union keyword.

class identifier 
struct identifier 
enum identifier 
union identifier

精心设计的类型说明符用于强调,或者显示由变量声明隐藏的类型名称

An elaborated type specifier is used either for emphasis, or to reveal a type name that is hidden by the declaration of a variable with the same name in the same scope.

source

这篇关于'class'关键字在C ++中的变量定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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