本篇 ShengYu 介紹 C++ std::array 用法與範例,std::array 是 C++ 標準函式庫提供的一個容器,用於表示固定大小的陣列。可以代替傳統的 C 陣列,它在某些情況下比傳統的 C 陣列更具優勢,因為它提供了更好的性能、更多的安全性與功能。接下來看看 std::array 用法範例。
要使用 std::array 的話,需要引入的標頭檔: <array>
C++ 建立 std::array
C++ std::array 的大小在建立時就被固定了,無法改變。這意味著它既提供了陣列的效率,又提供了容器的安全性。 你可以使用不同的方法來建立 std::array,範例如下,
~/bin $ crontab -l # Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command */5 * * * * /home/user/bin/xxx # 每隔 5 分鐘執行一次 59 23 * * * DISPLAY=:0 ~/crontab_script/xxx.sh # 23:59 時執行