016.Assign Operator 赋值运算
来源:互联网 发布:lvs 算法 编辑:程序博客网 时间:2024/06/07 06:39
--------------- main.m ---------------
#import<Foundation/Foundation.h>
intmain()
{
NSString* str = @"Objective-C"; // 将变量str赋值为Objective-C
double pi = 3.14; // 将变量pi赋值为3.14
BOOL visited = YES; // 将变量visited赋值为YES
//将变量str的值赋给str2
NSString *str2 = str;
int a;
int b;
int c;
{
NSString* str = @"Objective-C"; // 将变量str赋值为Objective-C
double pi = 3.14; // 将变量pi赋值为3.14
BOOL visited = YES; // 将变量visited赋值为YES
//将变量str的值赋给str2
NSString *str2 = str;
int a;
int b;
int c;
a = b = c =7; // 通过连续赋值对a, b, c赋值,三个变量的值都是7
NSLog(@"%d,%d,%d", a, b, c); // 输出三个变量的值
doubled1 = 12.34;
double d2 = d1 + 5;// 将表达式的值赋给d2
NSLog(@"%g”, d2); // 输出d2的值
}
一、编写本节代码的具体步骤:
1.参照003节的代码编写步骤。
二、本节代码涉及到的知识点:
1.赋值运算的运算符是=。
2.赋值表达式是有值的,赋值表达式的值就是右边被赋的值。
例如:NSString *str2 = str1; 该表达式的值就是str1。
0 0
- 016.Assign Operator 赋值运算
- 016.Assign Operator 赋值运算
- 016.Assign Operator 赋值运算
- 赋值运算符函数 operator=
- 赋值(assign)
- 赋值(assign)
- C++读书笔记之重载赋值运算符 overload assignment operator
- 重载赋值运算符(operator =)及swap
- (未完成)C++ 重载赋值运算函数 operator =
- 一文说尽C++赋值运算符重载函数(operator=)
- 一文说尽C++赋值运算符重载函数(operator=)
- 一文说尽C++赋值运算符重载函数(operator=)
- 深入分析C++赋值运算符重载函数(operator=)
- 一文说尽C++赋值运算符重载函数(operator=)
- assign连续赋值
- Boost assign赋值库
- assign 的模板赋值
- assign-----魔法赋值
- 014.Module Operator 模运算
- 我的Android进阶之旅------>如何在多个LinearLayout中添加分隔线
- html中的meta元素属性解析
- 2015.07.15-系统初始化首个任务时发生fault故障
- 015.Math Operator 复杂数学运算
- 016.Assign Operator 赋值运算
- 017.Bit Operator 位运算
- 018.Comparable Operator 比较运算
- 019.Logic Operator 逻辑运算
- 刷题日志——跳跃游戏
- Codeforces 501D Misha and Permutations Summation (康托展开+平衡树优化)
- 020.Comma Operator 逗号运算符
- 第三方登录(一)
- [leetcode] 172.Factorial Trailing Zeroes