【C++】POCO学习总结(十六):随机数、密码、时间戳、日期和时间(格式化与解析)、时区、本地时间

本文主要是介绍【C++】POCO学习总结(十六):随机数、密码、时间戳、日期和时间(格式化与解析)、时区、本地时间,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

【C++】郭老二博文之:C++目录

1、Poco::Random 随机数

1.1 说明

POCO包括一个伪随机数生成器(PRNG),使用非线性加性反馈算法,具有256位状态信息和长达269的周期。
PRNG可以生成31位的伪随机数。

它可以生成UInt32, char, bool, float和double随机值。
还可以提供随机字节流(使用/dev/random或Windows加密api)。

1.2 用法

Poco:::Random实现了一个伪随机数生成器(PRNG)。
头文件:#include “Poco/Random.h”

  • void seed(Poco::UInt32 seed)使用给定的种子为PRNG播种。
  • void seed()使用随机数据(来自Poco::RandomInputStream)播种PRNG

如果不使用seed(),POCO:::Random的构造函数只使用当前日期和时间生成伪随机数。
建议显式调用seed()方法,可以生成更理想的随机数。

  • UInt32 next():返回范围为[0,231]的伪随机数
  • UInt32 next(UInt32 n):返回范围为[0,n]的伪随机数。
  • char nextChar():返回一个伪随机字符
  • bool nextBool():返回一个伪随机布尔值
  • float nextFloat():返回范围为[0,1]的伪随机浮点值
  • double nextDouble():返回范围为[0,1]的伪随机浮点值

Poco::RandomInputStream是一个istream,它产生一个无限的随机字节序列。
随机字节取自/dev/random或Windows加密API(如果两者都不可用,Poco::RandomInputStream创建自己的随机数据)

1.3 示例

#include "Poco/Random.h"
#include "Poco/RandomStream.h"
#include <iostream>
using Poco::Random;
using Poco::RandomInputStream;
int main(int argc, char** argv)
{Random rnd;rnd.seed();std::cout << "Random integer: " << rnd.next() << std::endl;std::cout << "Random digit: " << rnd.next(10) << std::endl;std::cout << "Random char: " << rnd.nextChar() << std::endl;std::cout << "Random bool: " << rnd.nextBool() << std::endl;std::cout << "Random double: " << rnd.nextDouble() << std::endl;RandomInputStream ri;std::string rs;ri >> rs;return 0;
}

2、Poco::DigestEngine 加密

2.1 说明

POCO提供了一些广泛使用的加密散列函数的实现,包括如下加密:

MD2、MD4、 MD5、SHA1、HMAC

HMAC消息验证码算法(RFC 2104):HMAC是密钥相关的哈希运算消息认证码(Hash-based Message Authentication Code)的缩写。是一种基于Hash函数和密钥进行消息认证的方法。

所有哈希函数和HMAC的实现都是DigestEngine类的子类。
如果想实现自己的哈希函数,建议从DigestEngine派生。

2.2 用法

Poco::DigestEngine 定义了所有消息摘要算法实现的公共接口。
头文件:#include “Poco/DigestEngine.h”

加密后的输出数据的长度取决于算法。在POCO中,输出数据的类型是Digest(摘要),Digest其实就是std::vector<unsigned char>。
通过反复调用Poco::DigestEngine的update()方法,将数据传入算法中,当所有数据都传递给Poco::DigestEngine后,调用digest()方法来获取加密后的数据。

  • void update(const void * data, unsigned length):使用数据块更新Digest(摘要)
  • void update(char data):用一个字节的数据更新Digest(摘要)
  • void update(const std::string& data):使用数据字符串更新Digest(摘要)
  • const digest & digest():完成Digest计算并返回对Digest(摘要)的引用

常用加密算法,它们都是Poco::DigestEngine的子类

  • Poco::MD2Engine (#include "Poco/MD2Engine.h)
  • Poco::MD4Engine (#include "Poco/MD4Engine.h)
  • Poco::MD5Engine (#include "Poco/MD5Engine.h)
  • Poco::SHA1Engine (#include "Poco/SHA1Engine.h)
  • Poco::HMACEngine (#include "Poco/HMACEngine.h)

2.3 示例

#include "Poco/HMACEngine.h"
#include "Poco/SHA1Engine.h"
using Poco::DigestEngine;
using Poco::HMACEngine;
using Poco::SHA1Engine;
int main(int argc, char** argv)
{std::string message1("This is a top-secret message.");std::string message2("Don't tell anyone!");std::string passphrase("s3cr3t"); // HMAC需要一个密码短语HMACEngine<SHA1Engine> hmac(passphrase); // 计算一个HMAC-SHA1hmac.update(message1);hmac.update(message2);const DigestEngine::Digest& digest = hmac.digest();// 完成HMAC计算,得到摘要 digeststd::string digestString(DigestEngine::digestToHex(digest));// 转换为十六进制数字符串return 0;
}

3、流加密

3.1 说明

Poco::DigestInputStream和Poco::DigestOutputStream允许对写入输出流或从输入流读取的所有数据进行摘要计算。

Poco::DigestEngine必须传递给流的构造函数。然后,流将所有经过它们的数据传递给用于摘要计算的Poco::DigestEngine。
在写入Poco::DigestOutputStream后,始终刷新(flush())流以确保所有数据都被传递到摘要引擎。

3.2 示例

#include "Poco/DigestStream.h"
#include "Poco/MD5Engine.h"
using Poco::DigestOutputStream;
using Poco::DigestEngine;
using Poco::MD5Engine;
int main(int argc, char** argv)
{MD5Engine md5;DigestOutputStream ostr(md5);ostr << "This is some text";ostr.flush(); // 确保所有内容都被传递到摘要引擎const DigestEngine::Digest& digest = md5.digest(); // 获取结果std::string result = DigestEngine::digestToHex(digest);return 0;
}

4、Poco::Timestamp 时间戳

4.1 说明

Poco::Timestamp是Poco中时间戳。
头文件 #include “Poco/Timestamp.h”
Poco::Timestamp它存储一个基于UTC的64位时间值,(高达)微秒分辨率。实际的分辨率取决于操作系统。
由于Poco::Timestamp是基于UTC的,所以它独立于时区(并对其进行更改)。

Poco::Timestamp支持值语义、比较和简单算术。

Poco::Timestamp定义了一些公共类型:

  • TimeVal:是一个64位带符号的整数,以微秒的分辨率保存UTC时间
  • UtcTimeVal:是一个64位带符号的整数,保存着100纳秒分辨率的UTC时间(实际分辨率仍然<= 1 μs)
  • TimeDiff:一个64位带符号的整数,保存两者之间的差值
  • 时间戳以微秒为单位

在Unix中,纪元epoch时间是从1970年1月1日午夜开始以秒为单位测量的时间。
UTC(协调世界时)是从1582年10月15日午夜开始以100纳秒为间隔测量的时间。

4.2 用法

Poco::Timestamp的默认构造函数,用当前时间初始化时间戳Timestamp。

  • Timestamp fromEpochTime(time_t time):静态函数,获取从纪元epoch到现在的时间戳time_t
  • Timestamp fromUtcTime(UtcTimeVal val):获取UTC时间
  • time_t epochTime() const:返回time_t (epoch time)中表示的时间
  • UtcTimeVal utcTime() const:返回以UTC表示的时间,分辨率为100纳秒
  • TimeVal epochMicroseconds() const:返回自Unix纪元以来以微秒表示的时间时间戳
  • void update():用当前时间更新时间戳
  • timemediff elapsed() const:返回经过的微秒数时间戳
  • bool isElapsed(TimeDiff interval) const:如果从时间戳中存储的时间开始至少经过了interval微秒,则返回true

4.3 示例

#include "Poco/Timestamp.h"
#include <ctime>
using Poco::Timestamp;
int main(int argc, char** argv)
{Timestamp now; // 当前日期和时间std::time_t t1 = now.epochTime(); // Timestamp  转变为 time_t ...Timestamp ts1(Timestamp::fromEpochTime(t1)); // ... 转回Timestamp for (int i = 0; i < 100000; ++i) ; // 稍等一下Timestamp::TimeDiff diff = now.elapsed(); // 花了多长时间?Timestamp start(now); // 记录启动时间now.update(); // 更新当前时间 diff = now - start;return 0;
}

5、Poco::DateTime 日期和时间

5.1 说明

Poco::DateTime用于处理基于公历的日历日期和时间。
头文件: #include “Poco/DateTime.h”
Poco::DateTime常用于日期计算,如果要存储日期和时间,时间戳Poco::Timestamp类更合适。

Poco::DateTime在内部以两种格式维护日期和时间:
UTC和(年、月、日、时、分、秒、毫秒、微秒)。

公历,也叫格里高里历,几乎在世界各地都在使用。它的年份是根据耶稣基督的传统出生年份来编号的,这被标记为“纪元”时代。
它将天作为时间的基本单位,将它们分成365天或366天的年。一年分为12个月,长短不一。
并非所有国家都在同一时间采用公历(例如,德国在1582年,英国在1752年)。

儒略历(JDN)是从公元前4713年1月1日星期一开始的天数。这一天被记为朱利安零日。
因此,7的倍数是星期一。负值也可以使用。
儒略历日期(JD)是指从格林威治标准时间中午12点开始经过的天数(带有小数部分)

5.2 用法

5.2.1 常用成员函数

  • int year() const:返回年份
  • int month()返回月份:(1 - 12)
  • int week(int firstDayOfWeek = DateTime::MONDAY) const:根据ISO 8601返回一年内的周数
    (第1周为1月4日所在的一周);
    firstDayOfWeek应该是DateTime::MONDAY或DateTime::SUNDAY。
  • int day() const:返回一个月内的日期(1 - 31)
  • int dayOfWeek() const:返回一周内的日期
    (0 = DateTime::SUNDAY, 1 = DateTime::MONDAY,…,
    6 = DateTime::SATURDAY)
  • int dayOfYear() const:返回一年中的日期(1 - 366)
  • Int hour() const:返回小时(0 - 23)
  • int hourAMPM() const:返回小时(0 - 12)
  • bool isAM() const:返回true如果hour() < 12,否则返回false
  • bool isPM() const:返回true如果hour() >= 12,否则返回false
  • int minute() const:返回分钟数(0 - 59)
  • int second() const:返回秒(0 - 59)
  • int millisecond() const:返回毫秒数(0 - 999)
  • int microsecond() const:返回微秒数(0 - 999)
  • Timestamp timestamp() const:返回以时间戳形式表示的日期和时间
  • Timestamp::UtcTimeVal utcTime() const:返回以UTC时间表示的日期和时间
  • Poco::DateTime支持所有关系操作符(==, !=, >, >=, <, <=)
  • Poco::DateTime支持算法 (+, -, +=,-=)

5.2.2 常用静态函数

  • bool isLeapYear(int year):如果给定的年份是闰年则返回true,否则返回false
  • int daysOfMonth(int year, int month):返回给定年、月的天数
  • bool isValid(int year, int month, int day,int hour, int minute, int second, int millisecond, int microsecond)
    如果给定的日期和时间有效(所有参数都在适当的范围内)返回true,否则返回false(考虑闰年)

5.2.3 月、星期的枚举

Poco::DateTime具有月份和星期名称的枚举。这些可以用来代替数值:
1)月:Poco::DateTime::Months

  • JANUARY
  • FEBRUARY
  • MARCH
  • APRIL
  • MAY
  • JUNE
  • JULY
  • AUGUST
  • SEPTEMBER
  • OCTOBER
  • NOVEMBER
  • DECEMBER

2)星期:Poco::DateTime::DaysOfWeek

  • SUNDAY
  • MONDAY
  • TUESDAY
  • WEDNESDAY
  • THURSDAY
  • FRIDAY
  • SATURDAY

5.3 示例

#include "Poco/DateTime.h"
using Poco::DateTime;
int main(int argc, char** argv)
{DateTime now; // the current date and time in UTCint year = now.year();int month = now.month();int day = now.day();int dow = now.dayOfWeek();int doy = now.dayOfYear();int hour = now.hour();int hour12 = now.hourAMPM();int min = now.minute();int sec = now.second();int ms = now.millisecond();int us = now.microsecond();double jd = now.julianDay();Poco::Timestamp ts = now.timestamp();DateTime xmas(2006, 12, 25); // 2006-12-25 00:00:00Poco::Timespan timeToXmas = xmas - now;DateTime dt(1973, 9, 12, 2, 30, 45); // 1973-09-12 02:30:45dt.assign(2006, 10, 13, 13, 45, 12, 345); // 2006-10-13 12:45:12.345bool isAM = dt.isAM(); // falsebool isPM = dt.isPM(); // truebool isLeap = DateTime::isLeapYear(2006); // falseint days = DateTime::daysOfMonth(2006, 2); // 28bool isValid = DateTime::isValid(2006, 02, 29); // falsedt.assign(2006, DateTime::OCTOBER, 22); // 2006-10-22 00:00:00return 0;
}

6、Poco::LocalDateTime 本地时间

6.1 说明

Poco::LocalDateTime类似于Poco::DateTime,除了它存储本地时间(与UTC相反)和时区差异。
头文件:#include “Poco/LocalDateTime.h”
时区差是指UTC和本地时间之差,(UTC =本地时间-时区之差)。

Poco::LocalDateTime支持Poco::DateTime所有功能。

  • 所有关系运算符在执行比较之前都归一化为UTC。
  • int tzd() const返回时区差(秒)
  • Poco::DateTime utc() const将本地时间转换为utc时间

6.2 示例

#include "Poco/LocalDateTime.h"
using Poco::LocalDateTime;
int main(int argc, char** argv)
{LocalDateTime now; // 当前日期和本地时间int year = now.year();int month = now.month();int day = now.day();int dow = now.dayOfWeek();int doy = now.dayOfYear();int hour = now.hour();int hour12 = now.hourAMPM();int min = now.minute();int sec = now.second();int ms = now.millisecond();int us = now.microsecond();int tzd = now.tzd();double jd = now.julianDay();Poco::Timestamp ts = now.timestamp();LocalDateTime dt1(1973, 9, 12, 2, 30, 45); // 1973-09-12 02:30:45dt1.assign(2006, 10, 13, 13, 45, 12, 345); // 2006-10-13 12:45:12.345LocalDateTime dt2(3600, 1973, 9, 12, 2, 30, 45, 0, 0); // UTC +1 hourdt2.assign(3600, 2006, 10, 13, 13, 45, 12, 345, 0);Poco::Timestamp nowTS;LocalDateTime dt3(3600, nowTS); // 从时间戳构造return 0;
}

7、Poco::Timespan 时间跨度

7.1 说明

Poco::Timespan表示微秒级分辨率的时间跨度。
头文件:#include “Poco/Timespan.h”
在内部,Poco::Timespan使用64位整数来存储时间跨度。时间跨度可以用天、小时、分钟、秒、毫秒和微秒表示。

Poco::时间跨度定义了以下缩放因子:

  • MILLISECONDS毫秒中的微秒数
  • SECONDS一秒内的微秒数
  • MINUTES一分钟内的微秒数
  • HOURS一小时内的微秒数
  • DAYS一天中的微秒数

7.2 用法

  • int days() const:返回天数
  • int hours() const:返回一天中的小时数(0 - 23)
  • int totalHours() const:返回总小时数
  • int minutes() const:返回小时内的分钟数(0 - 59)
  • int totalMinutes() const:返回总分钟数
  • Int seconds() const:返回分钟内的秒数(0 - 60)
  • int totalSeconds() const:返回总秒数
  • int milliseconds() const:返回秒内的毫秒数(0 - 999)
  • int totalMilliseconds() const:返回总毫秒数
  • Int microseconds() const:返回毫秒内的微秒数(0 -999)
  • int totalMicroseconds() const:返回总微秒数

7.3 示例

#include "Poco/Timespan.h"
using Poco::Timespan;
int main(int argc, char** argv)
{Timespan ts1(1, 11, 45, 22, 123433); // 1d 11h 45m 22.123433sTimespan ts2(33*Timespan::SECONDS); // 33sTimespan ts3(2*Timespan::DAYS + 33*Timespan::HOURS); // 3d 33hint days = ts1.days(); // 1int hours = ts1.hours(); // 11int totalHours = ts1.totalHours(); // 35int minutes = ts1.minutes(); // 45int totalMins = ts1.totalMinutes(); // 2145int seconds = ts1.seconds(); // 22int totalSecs = ts1.totalSeconds(); // 128722return 0;
}

7.4 时间运算

#include "Poco/DateTime.h"
#include "Poco/Timespan.h"
using Poco::DateTime;
using Poco::Timespan;
int main(int argc, char** argv)
{DateTime birthdate(1973, 9, 12, 2, 30); // 1973-09-12 02:30:00DateTime now;Timespan age = now - birthdate;int days = age.days(); // in daysint hours = age.totalHours(); // in hoursint secs = age.totalSeconds(); // in secondsTimespan span(10000*Timespan::DAYS);DateTime dt = birthdate + span;return 0;
}

8、Poco::Timezone 系统时区

8.1 说明

Poco::Timezone 提供了获取系统时区信息的静态方法
头文件:#include “Poco/Timezone.h”

  • int utcOffset():返回本地时间到UTC的偏移量,以秒为单位,不包括夏令时DST
    (local time = UTC + utcOffset())
  • int DST():返回夏令时偏移量,以秒为单位(通常为3600)夏令时生效,否则为0。
  • bool isDst(const timestamp & timestamp):返回true,如果DST在给定时间有效
  • int tzd():返回当前时区的时区差异(tzd = utcOffset() + dst())
  • string name():返回当前生效的时区名称
  • std::string standardName():返回时区的名称,如果DST没有生效
  • std::string dstName():返回夏令时生效时的时区名称
  • 报告的名称依赖于操作系统,不能跨系统移植。

8.2 示例

#include "Poco/Timezone.h"
#include "Poco/Timestamp.h"
using Poco::Timezone;
using Poco::Timestamp;
int main(int argc, char** argv)
{int utcOffset = Timezone::utcOffset();int dst = Timezone::dst();bool isDst = Timezone::isDst(Timestamp());int tzd = Timezone::tzd();std::string name = Timezone::name();std::string stdName = Timezone::standardName();std::string dstName = Timezone::dstName();return 0;
}

9、Poco::DateTimeFormatter 格式化日期和时间

9.1 说明

Poco::DateTimeFormatter 可用于格式化日期和时间
(Timestamp, DateTime, LocalDateTime和Timespan)作为字符串。
头文件: #include “Poco/DateTimeFormat.h”
Poco::DateTimeFormatter使用类似于strftime()的格式字符串。

9.2 用法

Poco::DateTimeFormatter的所有函数都是静态的。

  • std::string format(const timestamp & timestamp, const std::string& fmt, int tzd = UTC)
    根据给定的格式字符串fmt格式化给定的时间戳。时区差值(tzd)是可选的。
  • std::string format(const dateTime & dateTime, const std::string& fmt, int tzd = UTC)
    类似于前一个函数,不同之处是这个函数接受DateTime
  • std::string format(const LocalDateTime& dateTime, const std::string& fmt)
    接受一个LocalDateTime(包含时区差异),并根据格式字符串fmt对其进行格式化
  • std::string format(const timespan & timespan, const std::string& fmt)
    根据格式字符串fmt格式化给定的时间跨度

几种常用的,已定义好的格式

  • ISO8601_FORMAT (2005-01-01T12:00:00+01:00)
  • RFC1123_FORMAT (Sat, 1 Jan 2005 12:00:00 +0100)
  • SORTABLE_FORMAT (2005-01-01 12:00:00)

9.3 示例

#include "Poco/DateTime.h"
#include "Poco/Timestamp.h"
#include "Poco/Timespan.h"
#include "Poco/DateTimeFormatter.h"
#include "Poco/DateTimeFormat.h"
using Poco::DateTimeFormatter;
using Poco::DateTimeFormat;
int main(int argc, char** argv)
{Poco::DateTime dt(2006, 10, 22, 15, 22, 34);std::string s(DateTimeFormatter::format(dt, "%e %b %Y %H:%M")); // "22 Oct 2006 15:22"Poco::Timestamp now;s = DateTimeFormatter::format(now, DateTimeFormat::SORTABLE_FORMAT);// "2006-10-30 09:27:44"Poco::Timespan span(5, 11, 33, 0, 0);s = DateTimeFormatter::format(span, "%d days, %H hours, %M minutes");// "5 days, 11 hours, 33 minutes"return 0;
}

10、Poco::DateTimeParser 从字符串中解析日期和时间

10.1 说明

可以使用Poco::DateTimeParser从字符串中解析日期和时间。
头文件: #include “Poco/DateTimeParser.h”
Poco::DateTimeParser总是返回一个Poco::DateTime和一个时区差值。然后可以将Poco::DateTime转换为Poco::Timestamp或Poco::LocalDateTime。
Poco::DateTimeParser的所有函数都是静态的。
Poco::DateTimeParser用法和Poco::DateTimeFormatter类似。

10.2 用法

  • void parse(const std::string fmt, const std::string& str, DateTime& dateTime, int& tzd)
    从字符串 str 中以 fmt 给出的格式解析日期和时间。在dateTime中存储日期和时间,在tzd中存储时区差异。如果无法解析字符串,则抛出Poco::SyntaxException。
  • DateTime parse(const std::string& fmt, const std::string& str, int& tzd)
    与上面类似,但返回DateTime
  • bool tryParse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& tzd)
    尝试从字符串str中以fmt给出的格式解析日期和时间。如果成功,将日期和时间存储在dateTime中,并将时区差存储在tzd中。如果成功返回true,否则返回false。
  • void parse(const std::string& str, DateTime& dateTime, int& tzd)
    解析给定字符串 str 中的日期和时间,识别Poco::DateTimeFormat定义的所有标准日期/时间格式。
    如果无法识别格式,或者字符串与预期格式不匹配,则抛出Poco::SyntaxException
  • DateTime parse(const std::string& str, int& tzd) :同上
  • bool tryParse(const std::string& str, DateTime& dateTime, int& tzd):同上

10.3 示例

#include "Poco/DateTimeParser.h"
#include "Poco/DateTime.h"
#include "Poco/DateTimeFormat.h"
#include "Poco/LocalDateTime.h"
#include "Poco/Timestamp.h"
using Poco::DateTimeParser;
using Poco::DateTimeFormat;
using Poco::DateTime;
int main(int argc, char** argv)
{std::string s("Sat, 1 Jan 2005 12:00:00 GMT");int tzd;DateTime dt;DateTimeParser::parse(DateTimeFormat::RFC1123_FORMAT, s, dt, tzd);Poco::Timestamp ts = dt.timestamp();Poco::LocalDateTime ldt(tzd, dt);bool ok = DateTimeParser::tryParse("2006-10-22", dt, tzd);ok = DateTimeParser::tryParse("%e.%n.%Y", "22.10.2006", dt, tzd);return 0;
}

这篇关于【C++】POCO学习总结(十六):随机数、密码、时间戳、日期和时间(格式化与解析)、时区、本地时间的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/509073

相关文章

关于C++中的虚拟继承的一些总结(虚拟继承,覆盖,派生,隐藏)

1.为什么要引入虚拟继承 虚拟继承是多重继承中特有的概念。虚拟基类是为解决多重继承而出现的。如:类D继承自类B1、B2,而类B1、B2都继承自类A,因此在类D中两次出现类A中的变量和函数。为了节省内存空间,可以将B1、B2对A的继承定义为虚拟继承,而A就成了虚拟基类。实现的代码如下: class A class B1:public virtual A; class B2:pu

C++对象布局及多态实现探索之内存布局(整理的很多链接)

本文通过观察对象的内存布局,跟踪函数调用的汇编代码。分析了C++对象内存的布局情况,虚函数的执行方式,以及虚继承,等等 文章链接:http://dev.yesky.com/254/2191254.shtml      论C/C++函数间动态内存的传递 (2005-07-30)   当你涉及到C/C++的核心编程的时候,你会无止境地与内存管理打交道。 文章链接:http://dev.yesky

51单片机学习记录———定时器

文章目录 前言一、定时器介绍二、STC89C52定时器资源三、定时器框图四、定时器模式五、定时器相关寄存器六、定时器练习 前言 一个学习嵌入式的小白~ 有问题评论区或私信指出~ 提示:以下是本篇文章正文内容,下面案例可供参考 一、定时器介绍 定时器介绍:51单片机的定时器属于单片机的内部资源,其电路的连接和运转均在单片机内部完成。 定时器作用: 1.用于计数系统,可

C++的模板(八):子系统

平常所见的大部分模板代码,模板所传的参数类型,到了模板里面,或实例化为对象,或嵌入模板内部结构中,或在模板内又派生了子类。不管怎样,最终他们在模板内,直接或间接,都实例化成对象了。 但这不是唯一的用法。试想一下。如果在模板内限制调用参数类型的构造函数会发生什么?参数类的对象在模板内无法构造。他们只能从模板的成员函数传入。模板不保存这些对象或者只保存他们的指针。因为构造函数被分离,这些指针在模板外

问题:第一次世界大战的起止时间是 #其他#学习方法#微信

问题:第一次世界大战的起止时间是 A.1913 ~1918 年 B.1913 ~1918 年 C.1914 ~1918 年 D.1914 ~1919 年 参考答案如图所示

[word] word设置上标快捷键 #学习方法#其他#媒体

word设置上标快捷键 办公中,少不了使用word,这个是大家必备的软件,今天给大家分享word设置上标快捷键,希望在办公中能帮到您! 1、添加上标 在录入一些公式,或者是化学产品时,需要添加上标内容,按下快捷键Ctrl+shift++就能将需要的内容设置为上标符号。 word设置上标快捷键的方法就是以上内容了,需要的小伙伴都可以试一试呢!

AssetBundle学习笔记

AssetBundle是unity自定义的资源格式,通过调用引擎的资源打包接口对资源进行打包成.assetbundle格式的资源包。本文介绍了AssetBundle的生成,使用,加载,卸载以及Unity资源更新的一个基本步骤。 目录 1.定义: 2.AssetBundle的生成: 1)设置AssetBundle包的属性——通过编辑器界面 补充:分组策略 2)调用引擎接口API

C++工程编译链接错误汇总VisualStudio

目录 一些小的知识点 make工具 可以使用windows下的事件查看器崩溃的地方 dumpbin工具查看dll是32位还是64位的 _MSC_VER .cc 和.cpp 【VC++目录中的包含目录】 vs 【C/C++常规中的附加包含目录】——头文件所在目录如何怎么添加,添加了以后搜索头文件就会到这些个路径下搜索了 include<> 和 include"" WinMain 和

Javascript高级程序设计(第四版)--学习记录之变量、内存

原始值与引用值 原始值:简单的数据即基础数据类型,按值访问。 引用值:由多个值构成的对象即复杂数据类型,按引用访问。 动态属性 对于引用值而言,可以随时添加、修改和删除其属性和方法。 let person = new Object();person.name = 'Jason';person.age = 42;console.log(person.name,person.age);//'J

大学湖北中医药大学法医学试题及答案,分享几个实用搜题和学习工具 #微信#学习方法#职场发展

今天分享拥有拍照搜题、文字搜题、语音搜题、多重搜题等搜题模式,可以快速查找问题解析,加深对题目答案的理解。 1.快练题 这是一个网站 找题的网站海量题库,在线搜题,快速刷题~为您提供百万优质题库,直接搜索题库名称,支持多种刷题模式:顺序练习、语音听题、本地搜题、顺序阅读、模拟考试、组卷考试、赶快下载吧! 2.彩虹搜题 这是个老公众号了 支持手写输入,截图搜题,详细步骤,解题必备