一.function alias invocation(引用)
#include <iostream>
using namespace std;
void aliasFun(int &, int &);
int main()
{
int num = 10;
cout << "Num = " << num << endl;
int &i = num;
i = 20;
cout << "i = " << i << endl;
cout << "Num = " << num << endl;
int x = 200;
int y = 300;
aliasFun(x,y);
cout << "x = " << x << ", " << "y = " << y << endl;
return 0;
}
void aliasFun(int &a,int &b)
{
a = 4;
b = 10;
}
--------------------------------------------
二.type cast
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
double d = 3.1415926;
int i1 = static_cast<int>(d);
int i2 = (int)d; // old method
cout << "i1 = " << i1 << endl;
cout << "i2 = " << i2 << endl;
return 0;
}
-----------------------------------------
3.Array definition
int a[4]; // definition
int a[4] = {1,10,2,4} // defination and initialization
------------------------------------------
4.pointer
int a = 10;
int *p = &a;
int *p = new int;
int *p = new int[10]; //dynamic allocate array
delete p;
delete [] p;
void swap(int *num1,int *num2)
{
int temp = *num1;
*num1 = *num2;
*num2 = temp;
}
int main(){
int x = 10;
int y = 20;
swap(&x,&y);
}
-------------------------------
5.character && string
char *p = "hello very good";
while(p != "\0")
{
cout << *p++;
}
------------
char str[10] = "hello!";
char *p = str;
for(int i=0;i<6;i++)
{
cout << *(p+i);
}
分享到:
相关推荐
Concentrating on the ... Most importantly, Realistic Ray Tracing adds many C++ code segments, and adds new details to provide the reader with a better intuitive understanding of ray tracing algorithms.
Utilize real-world program segments in your own applications C++ is notoriously complex, and whether you use it for gaming or business, maximizing its functionality means keeping up to date with the ...
The goal of this guide is to manage this complexity by describing in detail the dos and don'ts of writing C++ code. These rules exist to keep the code base manageable while still allowing coders to ...
A solid foundation in the basics of C++ programming will allow readers to create efficient, elegant code ready for any production environment Learning basic logic and fundamental programming ...
201 | [Bitwise AND of Numbers Range](https://leetcode.com/problems/bitwise-and-of-numbers-range/) | [C++](./C++/bitwise-and-of-numbers-range.cpp) [Python](./Python/bitwise-and-of-numbers-range.py) | _...
**4.5 代码段 (CODE SEGMENTS)** - **中断向量及复位向量 (INTERRUPT AND RESET VECTORS)**:介绍了中断向量表的作用和结构。 - **函数 (FUNCTIONS)**:解释了如何在代码段中放置函数。 **4.6 编译器生成的段 ...
// Code segments - maybe placed anywhere in memory. // ------------- // // INTVEC -- Exception vector table. // SWITAB -- Software interrupt vector table. // ICODE -- Startup (cstartup) and exception ...
OllyDbg 可以扫描Object文件/库(包括 OMF 和 COFF 格式),解压代码段[code segments]并且对其位置进行定向。 Implib扫描。 由于一些DLL文件的输出函数使用的索引号,对于人来说,这些索引号没有实际含义。如果...
书中还介绍了两次通过链接(Two-pass linking),这通常用于处理对象代码库(Object code libraries)和重定位(Relocation)以及代码修改。 书中的第二章专注于系统架构相关问题,例如应用二进制接口(Application...
- **C++重复移除**:在C++编程中,为了避免多次定义相同的全局对象,编译器会在链接阶段自动去除重复的定义。 #### 结论 通过以上内容,我们可以看出链接器与加载器在计算机程序的构建和运行中扮演着极其重要的...
- **特殊段(Common Blocks and Other Special Segments)**:例如C++的静态对象构造和析构函数,以及IBM 360架构中的RLD和END记录。 书中通过丰富的实例和深入的分析,阐述了链接和加载过程中的复杂性,并提供了...
- FIX Add moving block for first and last connector's segments also for non-orthogonal connectors. - FIX Class TPenProp rewrote without TPen delphi object. - FIX In some cases TFlexCurve.Paint ...
确保系统已经安装了兼容的C++库。在Linux环境下,通常需要安装`compat-libstdc++`包。例如,在安装盘上找到`compat-libstdc++-7.3-2.96.118.i386.rpm`或`compat-libstdc++-33-3.2.3-47.3.x86_64.rpm`,然后使用以下...
docking.zip This ActiveX control and Demo will allow you to dock your toolbars/forms to a mdiform much in the way in which Visual C++ allows you to. <END><br>17 , resizable7segment_source.zip An...
Using Visual C++ .NET 284 Using Visual Basic .NET 286 Finding Your Device 291 Obtaining the Device Interface GUID 292 Requesting a Pointer to a Device Information Set 293 Identifying a Device ...
首先,`code.ino`是Arduino项目的源代码文件,它包含了用C++编写的程序。在这个项目中,我们需要理解如何编写Arduino代码来控制七段显示器。代码通常会包括初始化引脚(pin setup),设置计数器变量,以及定义函数来...