Primary Expression
Primary expressions are the building blocks of more complex expressions. They are literals, names, and names qualified by the scope-resolution operator (::). A primary expression may have any of the following forms:
literal
this
:: name
name
( expression )
A literal is a constant primary expression. Its type depends on the form of its specification. See Literals for complete information about specifying literals.
The this keyword is a pointer to a class object. It is available within nonstatic member functions and points to the instance of the class for which the function was invoked. The this keyword cannot be used outside the body of a class-member function.
The type of the this pointer is type *const (where type is the class name) within functions not specifically modifying the this pointer. The following example shows member function declarations and the types of this:
// expre_Primary_Expressions.cpp
// compile with: /LD
class Example
{
public:
void Func(); // * const this
void Func() const; // const * const this
void Func() volatile; // volatile * const this
};
See Type of this Pointer for more information about modifying the type of the this pointer.
The scope-resolution operator (::) followed by a name constitutes a primary expression. Such names must be names at global scope, not member names. The type of this expression is determined by the declaration of the name. It is an l-value (that is, it can appear on the left hand side of an assignment operator expression) if the declaring name is an l-value. The scope-resolution operator allows a global name to be referred to, even if that name is hidden in the current scope. See Scope for an example of how to use the scope-resolution operator.
An expression enclosed in parentheses is a primary expression whose type and value are identical to those of the unparenthesized expression. It is an l-value if the unparenthesized expression is an l-value.
In the context of the primary expression syntax given above, name means anything in the syntax described for Names, although when using the scope-resolution operator before the name, types of names that can only occur in a class are not allowed. This includes user-defined conversion function names, and destructor names.
Examples of primary expressions include:
100 // literal
'c' // literal
this // in a member function, a pointer to the class instance
::func // a global function
::operator + // a global operator function
::A::B // a global qualified name
( i + 1 ) // a parenthesized expression
The examples below are all considered names, and hence primary expressions, in various forms:
MyClass // a identifier
MyClass::f // a qualified name
operator = // an operator function name
operator char* // a conversion operator function name
~MyClass // a destructor name
A::B // a qualified name
A<int> // a template id
Is this page helpful?
Primary Expression的更多相关文章
- javascript 核心语言笔记 4 - 表达式和运算符
表达式(expression)是 JavaScript 中的一个短语(phrases),JavaScript 解释器会将其计算(evaluate)出一个结果.程序中的常量.变量名.数组访问等都是表达式 ...
- angular源码分析:angular中脏活累活承担者之$parse
我们在上一期中讲 $rootscope时,看到$rootscope是依赖$prase,其实不止是$rootscope,翻看angular的源码随便翻翻就可以发现很多地方是依赖于$parse的.而$pa ...
- go语言的selector
For a primary expression x that is not a package name, the selector expression x.f denotes the field ...
- 【C】 04 - 表达式和语句
程序的生命力体现在它千变万化的行为,而再复杂的系统都是由最基本的语句组成的.C语句形式简单自由,但功能强大.从规范的角度学习C语法,一切显得简单而透彻,无需困扰于各种奇怪的语法. 1. 表达式(exp ...
- javascript5
调用对象call object: 声明上下文对象declarative environment record; 作用域链scopechain: 变量解析:variable resolution: 引用 ...
- Method Invocation Expressions
15.12.1. Compile-Time Step 1: Determine Class or Interface to Search The first step in processin ...
- C++程序设计语言(特别版) -- 一个桌面计算器
前言 这里要介绍各种语句和表达式,将通过一个桌面计算器的程序做些事情,该计算器提供四种座位浮点数的中缀运算符的标准算术运算. 这个计算器由四个部分组成:一个分析器,一个输入函数,一个符号表和一个驱动程 ...
- 笔记《JavaScript 权威指南》(第6版) 分条知识点概要3—表达式和运算符
[表达式和运算符]原始表达式,初始化表达式(对象和数组的),函数定义表达式,属性访问表达式,调用表达式,对象创建表达式,运算符概述,算术表达式,关系表达式,逻辑表达式,赋值表达式,表达式计算,其他运算 ...
- Swift5 语言参考(十) 语法汇总
词法结构 GRAMMAR OF WHITESPACE whitespace → whitespace-item whitespace opt whitespace-item → line-break ...
随机推荐
- 高效算法——D 贪心,区间覆盖问题
Given several segments of line (int the X axis) with coordinates [Li , Ri ]. You are to choose the m ...
- 控制uwsgi 的信号量
最近在用nginx+uwsgi+djano搭建一个网站,当.py文件修改后,如果不重启uwsgi,修改无法应用. 查了下uwsgi的相关文档 ,找到几个解决方案.顺便翻译下以备查看 启动服务 Star ...
- openStack 云平台管理节点管理网口流量非常大 出现丢包严重 终端总是时常中断问题调试及当前测试较有效方案
tuning for Data Transfer hosts connected at speeds of 1Gbps or higher <一.本次OpenStack系统调试简单过程简单记录& ...
- VGO新闻 - VGO
VGO新闻 - VGO VGO天津伊势丹店盛装揭幕 VGO天津伊势丹店盛装揭幕2013年9月7日,VGO(微高)全国首家实体店在天津伊势丹百货盛装开幕.现场,100多位商场领导及业内同仁共同出席了
- Python读写文件模式
1.r 打开只读文件,该文件必须存在. 2.r+ 打开可读写的文件,该文件必须存在. 3.w 打开只写文件,若文件存在则文件长度清为0,即该文件内容会消失.若文件不存在则建立该文件. 4.w+ 打开可 ...
- Java model 对象处理
public class BaseFlowBo { /** * 流量 */ private String flow; /** * Pv */ private String pv; /** * CTR ...
- border、margin、padding属性的区别
可以先看下这个视频教程:http://my.tv.sohu.com/us/97014746/64226777.shtml 本文参考:http://www.cnblogs.com/chinhr/arch ...
- Java串口通信具体解释
序言 说到开源,恐怕非常少有人不挑大指称赞.学生通过开源码学到了知识,程序猿通过开源类库获得了别人的成功经验及可以按时完毕手头的project,商家通过开源软件赚到了钱……,总之是皆大欢喜.然而开源软 ...
- 解密-神秘的 RunLoop
引言 一直以来RunLoop就是个神秘的领域,好多2.3年的开发者都不能准确的表述它的作用,说它神秘,其实RunLoop并没有大家想象中的那么神秘,那么不好理解,本文就带大家好好剖析一下”神秘的Run ...
- SDK目录结构和adb工具及命令介绍
1.SDK目录介绍: ******************************** add-ons:Android开发需要的第三方文件,附加的库,如Google APIs.GoogleMaps. ...