The summary of C++

The summary of C++


The Size of the Primitive Data

TypeSizeRange
void0N/A
bool1 byteN/A
short2 bytes-0x8000~0x7FFF
unsigned short2 bytes0~0xFFFF
int4 bytes-0x80000000~0x7FFFFFFF
unsigned int4 bytes0xFFFFFFFF
long4 bytes-0x80000000~0x7FFFFFFF
unsigned long4 bytes0~0xFFFFFFFF
long long8 bytes0~0xFFFFFFFFFFFFFFFF
char1 byte-0x80~0x7F
unsigned char1 byte0~0xFF
wchar_t2 bytes0~0xFFFF
float4 bytes3.4E-38~3.4E+38
double8 bytes1.7E-308~1.7E+308
long double8 bytes

* 以上sizeof通过Windows XP 32位平台测试,其中某些类型数据的字节数和数值范围由操作系统和编译平台决定。比如16位机上,sizeof(int) = 2,而32位机上sizeof(int) = 4;32位机上sizeof(long) = 4,而64位机上sizeof(long) = 8。除此之外,注意64位机上的pointer占8byte


Numeric Type Data Conversion

Priority:
long double > double > float > unsigned long > long > unsigned int > int
Syntax:

static_cast<type>(value) or (type)value

The principle of Function call

Each time a function is invoked, the system stores its arguments and variables in an area of memory, known as stack, which stores elements in last-in-first-out fashion. When a function calls another function , the caller’s stack space is kept intact, and new space is created to handle the new function call. When a function finishes its work and returns to its caller, its associated space is released.


Passing Parameters by Values and by References

Passing Parameters by Values:

void increment(int n)

Passing Parameters by References:

void swap(int &n1, int &n2)

Static Local Variables

After a function completes its executions, all its local variables are destroyed. Sometimes, it is desirable to retain the value stored in local variables so that they can be used in the next call. C++ allow us to use static local variables to do this.

static int x = 1;

操作系统代码实现:Number Project Name Content Summary State Type 一、Process Scheduling Algorithm Simulation 1、 Simulate the operation of the round-robin algorithm for process scheduling. 2、 Create at least 15 processes and output their scheduling situation under the scheduling algorithm mentioned above and output it to theterminal to check the execution of the algorithm. 3、 The output should include the arrival time of the processes, the end time, and the average execution time. Essential. General 二、Readers-Writer Problem Implmentation 1、 A data set is shared among several concurrent processes: Readers – only read the data set; they do not perform any updates. Writers – can both read and write. 2、 Problem – allow multiple readers (at most 8) to read at the same time. Only one single writer can access the shared data at the same time. Essential. General 三、Program for Least Recently used Algorithm 1、 Create a page access sequence (page number range 0-18) using a random function. The sequence length is 54 and assume that the number of main memory frames allocated to the thread is 6, that is, M = 6. 2、 Implement the LRU algorithm for page replacement on the above access sequence. 3、 Output the page replacement sequence and the page fault rate. Essential. General Requirements 1、 For each experiment project, submit a design report and code. The code should be implemented in C++. The requirements are as follows: a) The content of the design report should include the design ideas and implementation. b) The results of the design report should include testing and running results (screenshots of screen outputs). c) The conclusion of the design report should summarize the problems encountered, the solutions and experiences during the implementation process.
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值