您现在的位置是:首页 > 正文

C++ 类型转换(内置类型,string、char*、const char*等)

2024-02-01 02:43:09阅读 2

目录

类型

转换

全部代码


文章适用于已经学了C++语言,对C++类型有一定了解的朋友。对类型转换进行总结,包括内置类型,string,以及由c语言引入的一些类型。

类型

内置数据类型 字节 范围
char 1 个字节 -128 到 127 或者 0 到 255
unsigned char 1 个字节 0 到 255
signed char 1 个字节 -128 到 127
int 4 个字节 -2147483648 到 2147483647
unsigned int 4 个字节 0 到 4294967295
signed int 4 个字节 -2147483648 到 2147483647
short int 2 个字节 -32768 到 32767
unsigned short int 2 个字节 0 到 65,535
signed short int 2 个字节 -32768 到 32767
long int 8 个字节 -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807
signed long int 8 个字节 -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807
unsigned long int 8 个字节 0 到 18,446,744,073,709,551,615
float 4 个字节 精度型占4个字节(32位)内存空间,+/- 3.4e +/- 38 (~7 个数字)
double 8 个字节 双精度型占8 个字节(64位)内存空间,+/- 1.7e +/- 308 (~15 个数字)
long double 16 个字节 长双精度型 16 个字节(128位)内存空间,可提供18-19位有效数字。
wchar_t 2 或 4 个字节 1 个宽字符

字符串

string C++的类

C风格 const char*、char*、char[]

转换

C++类型转换主要分为两种:隐式类型转换、显式类型转换(强制类型转换)。

所谓隐式类型转换,是指不需要用户干预,编译器默认进行的类型转换行为。

四种强制类型转换操作符:static_cast、const_cast、dynamic_cast、reinterpret_cast

还有类的构造方法,类的方法、流等

类型转换及方法
类型转换左转右 方法
char->其他内置类型及const char*、char* 隐式转换
unsigned char、signed char->其他内置类型 隐式转换
unsigned char、signed char->const char*、char* 先转为char,再隐式转换
char、unsigned char、signed char->string 构造方法,push_back、insert等方法
[signed/unsigned] [short/long] int->[signed/unsigned] char +'0'  数值为0~9
[signed/unsigned] [short/long] int->float/[long] double或[signed/unsigned] [short/long] int 隐式转换
float/[long] double -> [signed/unsigned] [short/long] int 显示转换,否则警告(例如,warning C4244: “初始化”: 从“float”转换到“short”,可能丢失数据)
string->const char * 使用string的c_str()函数
string->const char *->char* 先转const char *,再使用const_cast<char*>()转char*
[const] char *->string 隐式转换
const char *->char* 使用const_cast<char*>()转char*
[const] char *->char[] 使用strncpy_s()函数
char* ->const char* 隐式转换

注:[]表示可选,/表示或者

总结

内置类型隐式转换即可,可能丢失数据

涉及指针使用const_cast,涉及string类使用方法push_back、c_str等

建议不要使用C风格的const char *、char[]等,string不香吗???

    string s("nkjsf");
    const char* ch = s.c_str();
    cout << ch << endl;
    s = "efefd";
    cout << ch << endl;

nkjsf

efefd

ch没有变,但是两次输出不一样。各位学完C再学C++的,字符串这里学学string吧,真的很不错。

全部代码

测试了部分,运行单个函数即可。

/*
Project:TypeConvert
Date:    2020/09/06
Author:  Frank Yu
*/
#include<iostream>
#include<string>
#include<typeinfo>
using namespace std;

void display(string type,string method)
{
	cout <<"转为:"<<type<< ",使用方法:" << method << endl;
}

void char2other(char c)
{
	unsigned char uc = c;
	display("unsigned char","隐式转换");
	cout << "转换后:" << uc<<endl;
	signed char sc = c;
	display("signed char", "隐式转换");
	cout << "转换后:" << sc << endl;
	int i = c;
	display("int", "隐式转换");
	cout << "转换后:" << i << endl;
	unsigned int ui = c;
	display("unsigned int", "隐式转换");
	cout << "转换后:" << ui << endl;
	signed int si = c;
	display("signed int", "隐式转换");
	cout << "转换后:" << si << endl;
	unsigned short int usi = c;
	display("unsigned short int", "隐式转换");
	cout << "转换后:" << usi << endl;
	short int s_i = c;
	display("short int", "隐式转换");
	cout << "转换后:" << s_i << endl;
	long int li = c;
	display("long int", "隐式转换");
	cout << "转换后:" << li << endl;
	signed long int sli = c;
	display("signed long int", "隐式转换");
	cout << "转换后:" << sli << endl;
	unsigned long int uli = c;
	display("unsigned long int", "隐式转换");
	cout << "转换后:" << uli << endl;
	float f = c;
	display("float", "隐式转换");
	cout << "转换后:" << f << endl;
	double d = c;
	display("double", "隐式转换");
	cout << "转换后:" << d << endl;
	long double ld = c;
	display("long double", "隐式转换");
	cout << "转换后:" << ld << endl;
	wchar_t wc = c;
	display("wchar_t", "隐式转换");
	cout << "转换后:" << wc << endl;
	string s(1,c);
	display("string", "构造方法string(size_t n,char c)");
	cout << "转换后:" << s << endl;
	string s1;
	s1.push_back(c);
	display("string", "push_back");
	cout << "转换后:" << s1 << endl;
	const char* cc = &c;
	display("const char*", "隐式转换");
	cout << "转换后:" << cc << endl;
	char* c_c = &c;
	display("char*", "隐式转换");
	cout << "转换后:" << c_c << endl;
}

void unsignedchar2other(unsigned char c)
{
	char uc = c;
	display("char", "隐式转换");
	cout << "转换后:" << uc << endl;
	signed char sc = c;
	display("signed char", "隐式转换");
	cout << "转换后:" << sc << endl;
	int i = c;
	display("int", "隐式转换");
	cout << "转换后:" << i << endl;
	unsigned int ui = c;
	display("unsigned int", "隐式转换");
	cout << "转换后:" << ui << endl;
	signed int si = c;
	display("signed int", "隐式转换");
	cout << "转换后:" << si << endl;
	unsigned short int usi = c;
	display("unsigned short int", "隐式转换");
	cout << "转换后:" << usi << endl;
	short int s_i = c;
	display("short int", "隐式转换");
	cout << "转换后:" << s_i << endl;
	long int li = c;
	display("long int", "隐式转换");
	cout << "转换后:" << li << endl;
	signed long int sli = c;
	display("signed long int", "隐式转换");
	cout << "转换后:" << sli << endl;
	unsigned long int uli = c;
	display("unsigned long int", "隐式转换");
	cout << "转换后:" << uli << endl;
	float f = c;
	display("float", "隐式转换");
	cout << "转换后:" << f << endl;
	double d = c;
	display("double", "隐式转换");
	cout << "转换后:" << d << endl;
	long double ld = c;
	display("long double", "隐式转换");
	cout << "转换后:" << ld << endl;
	wchar_t wc = c;
	display("wchar_t", "隐式转换");
	cout << "转换后:" << wc << endl;
	string s(1, c);
	display("string", "构造方法string(size_t n,char c)");
	cout << "转换后:" << s << endl;
	string s1;
	s1.push_back(c);
	display("string", "push_back");
	cout << "转换后:" << s1 << endl;
	//先转为了char,因为直接转不行(unsigned char *无法转为const char *)
	char h = c;
	const char* cc = &h;
	display("const char*", "显示转换");
	cout << "转换后:" << *cc << endl;
	char* c_c = &h;
	display("char*", "显示转换");
	cout << "转换后:" << *c_c << endl;
}

void signedchar2other(signed char c)
{
	char uc = c;
	display("char", "隐式转换");
	bool b = uc == c;
	cout << b;
	if (uc == c)cout << b;
	cout << "转换后:" << uc << endl;
	unsigned char sc = c;
	display("unsigned char", "隐式转换");
	cout << "转换后:" << sc << endl;
	int i = c;
	display("int", "隐式转换");
	cout << "转换后:" << i << endl;
	unsigned int ui = c;
	display("unsigned int", "隐式转换");
	cout << "转换后:" << ui << endl;
	signed int si = c;
	display("signed int", "隐式转换");
	cout << "转换后:" << si << endl;
	unsigned short int usi = c;
	display("unsigned short int", "隐式转换");
	cout << "转换后:" << usi << endl;
	short int s_i = c;
	display("short int", "隐式转换");
	cout << "转换后:" << s_i << endl;
	long int li = c;
	display("long int", "隐式转换");
	cout << "转换后:" << li << endl;
	signed long int sli = c;
	display("signed long int", "隐式转换");
	cout << "转换后:" << sli << endl;
	unsigned long int uli = c;
	display("unsigned long int", "隐式转换");
	cout << "转换后:" << uli << endl;
	float f = c;
	display("float", "隐式转换");
	cout << "转换后:" << f << endl;
	double d = c;
	display("double", "隐式转换");
	cout << "转换后:" << d << endl;
	long double ld = c;
	display("long double", "隐式转换");
	cout << "转换后:" << ld << endl;
	wchar_t wc = c;
	display("wchar_t", "隐式转换");
	cout << "转换后:" << wc << endl;
	string s(1, c);
	display("string", "构造方法string(size_t n,char c)");
	cout << "转换后:" << s << endl;
	string s1;
	s1.push_back(c);
	display("string", "push_back");
	cout << "转换后:" << s1 << endl;
	//先转为了char,因为直接转不行(signed char *无法转为const char *)
	char h = c;
	const char* cc = &h;
	display("const char*", "显示转换");
	cout << "转换后:" << *cc << endl;
	char* c_c = &h;
	display("char*", "显示转换");
	cout << "转换后:" << *c_c << endl;
}

void int2other(int i)
{
	char c = i+'0';
	display("int", "+'0'");
	cout << "转换后:" << c << endl;
	unsigned char uc = i+'0';
	display("unsigned char", "隐式转换");
	cout << "转换后:" << uc << endl;
	signed char sc = i + '0';
	display("signed char", "隐式转换");
	cout << "转换后:" << sc << endl;
	unsigned int ui = i;
	display("unsigned int", "隐式转换");
	cout << "转换后:" << ui << endl;
	signed int si = i;
	display("signed int", "隐式转换");
	cout << "转换后:" << si << endl;
	unsigned short int usi = i;
	display("unsigned short int", "隐式转换");
	cout << "转换后:" << usi << endl;
	short int s_i = i;
	display("short int", "隐式转换");
	cout << "转换后:" << s_i << endl;
	long int li = i;
	display("long int", "隐式转换");
	cout << "转换后:" << li << endl;
	signed long int sli = i;
	display("signed long int", "隐式转换");
	cout << "转换后:" << sli << endl;
	unsigned long int uli = i;
	display("unsigned long int", "隐式转换");
	cout << "转换后:" << uli << endl;
	float f = i;
	display("float", "隐式转换");
	cout << "转换后:" << f << endl;
	double d = i;
	display("double", "隐式转换");
	cout << "转换后:" << d << endl;
	long double ld = i;
	display("long double", "隐式转换");
	cout << "转换后:" << ld << endl;
	wchar_t wc = i;
	display("wchar_t", "隐式转换");
	cout << "转换后:" << wc << endl;
	string s(1, i+'0');
	display("string", "构造方法string(size_t n,char c)");
	cout << "转换后:" << s << endl;
	string s1;
	s1.push_back(i+'0');
	display("string", "push_back");
	cout << "转换后:" << s1 << endl;
	const char* cc = &c;
	display("const char*", "隐式转换");
	cout << "转换后:" << *cc << endl;
	char* c_c = &c;
	display("char*", "隐式转换");
	cout << "转换后:" << *c_c << endl;

}

void unsignedint2other(unsigned int i)
{
	char c = i + '0';
	display("int", "+'0'");
	cout << "转换后:" << c << endl;
	unsigned char uc = i + '0';
	display("unsigned char", "隐式转换");
	cout << "转换后:" << uc << endl;
	signed char sc = i + '0';
	display("signed char", "隐式转换");
	cout << "转换后:" << sc << endl;
	int ui = i;
	display("int", "隐式转换");
	cout << "转换后:" << ui << endl;
	signed int si = i;
	display("signed int", "隐式转换");
	cout << "转换后:" << si << endl;
	unsigned short int usi = i;
	display("unsigned short int", "隐式转换");
	cout << "转换后:" << usi << endl;
	short int s_i = i;
	display("short int", "隐式转换");
	cout << "转换后:" << s_i << endl;
	long int li = i;
	display("long int", "隐式转换");
	cout << "转换后:" << li << endl;
	signed long int sli = i;
	display("signed long int", "隐式转换");
	cout << "转换后:" << sli << endl;
	unsigned long int uli = i;
	display("unsigned long int", "隐式转换");
	cout << "转换后:" << uli << endl;
	float f = i;
	display("float", "隐式转换");
	cout << "转换后:" << f << endl;
	double d = i;
	display("double", "隐式转换");
	cout << "转换后:" << d << endl;
	long double ld = i;
	display("long double", "隐式转换");
	cout << "转换后:" << ld << endl;
	wchar_t wc = i;
	display("wchar_t", "隐式转换");
	cout << "转换后:" << wc << endl;
	string s(1, i + '0');
	display("string", "构造方法string(size_t n,char c)");
	cout << "转换后:" << s << endl;
	string s1;
	s1.push_back(i + '0');
	display("string", "push_back");
	cout << "转换后:" << s1 << endl;
	const char* cc = &c;
	display("const char*", "隐式转换");
	cout << "转换后:" << *cc << endl;
	char* c_c = &c;
	display("char*", "隐式转换");
	cout << "转换后:" << *c_c << endl;

}

void signedint2other(signed int i)
{
	char c = i + '0';
	display("int", "+'0'");
	cout << "转换后:" << c << endl;
	unsigned char uc = i + '0';
	display("unsigned char", "隐式转换");
	cout << "转换后:" << uc << endl;
	signed char sc = i + '0';
	display("signed char", "隐式转换");
	cout << "转换后:" << sc << endl;
	int ui = i;
	display("int", "隐式转换");
	cout << "转换后:" << ui << endl;
	unsigned int si = i;
	display("unsigned int", "隐式转换");
	cout << "转换后:" << si << endl;
	unsigned short int usi = i;
	display("unsigned short int", "隐式转换");
	cout << "转换后:" << usi << endl;
	short int s_i = i;
	display("short int", "隐式转换");
	cout << "转换后:" << s_i << endl;
	long int li = i;
	display("long int", "隐式转换");
	cout << "转换后:" << li << endl;
	signed long int sli = i;
	display("signed long int", "隐式转换");
	cout << "转换后:" << sli << endl;
	unsigned long int uli = i;
	display("unsigned long int", "隐式转换");
	cout << "转换后:" << uli << endl;
	float f = i;
	display("float", "隐式转换");
	cout << "转换后:" << f << endl;
	double d = i;
	display("double", "隐式转换");
	cout << "转换后:" << d << endl;
	long double ld = i;
	display("long double", "隐式转换");
	cout << "转换后:" << ld << endl;
	wchar_t wc = i;
	display("wchar_t", "隐式转换");
	cout << "转换后:" << wc << endl;
	string s(1, i + '0');
	display("string", "构造方法string(size_t n,char c)");
	cout << "转换后:" << s << endl;
	string s1;
	s1.push_back(i + '0');
	display("string", "push_back");
	cout << "转换后:" << s1 << endl;
	const char* cc = &c;
	display("const char*", "隐式转换");
	cout << "转换后:" << *cc << endl;
	char* c_c = &c;
	display("char*", "隐式转换");
	cout << "转换后:" << *c_c << endl;

}

void shortint2other(short int i)
{
	char c = i + '0';
	display("int", "+'0'");
	cout << "转换后:" << c << endl;
	unsigned char uc = i + '0';
	display("unsigned char", "隐式转换");
	cout << "转换后:" << uc << endl;
	signed char sc = i + '0';
	display("signed char", "隐式转换");
	cout << "转换后:" << sc << endl;
	int ui = i;
	display("int", "隐式转换");
	cout << "转换后:" << ui << endl;
	unsigned int si = i;
	display("unsigned int", "隐式转换");
	cout << "转换后:" << si << endl;
	unsigned short int usi = i;
	display("unsigned short int", "隐式转换");
	cout << "转换后:" << usi << endl;
	signed int s_i = i;
	display("signed int", "隐式转换");
	cout << "转换后:" << s_i << endl;
	long int li = i;
	display("long int", "隐式转换");
	cout << "转换后:" << li << endl;
	signed long int sli = i;
	display("signed long int", "隐式转换");
	cout << "转换后:" << sli << endl;
	unsigned long int uli = i;
	display("unsigned long int", "隐式转换");
	cout << "转换后:" << uli << endl;
	float f = i;
	display("float", "隐式转换");
	cout << "转换后:" << f << endl;
	double d = i;
	display("double", "隐式转换");
	cout << "转换后:" << d << endl;
	long double ld = i;
	display("long double", "隐式转换");
	cout << "转换后:" << ld << endl;
	wchar_t wc = i;
	display("wchar_t", "隐式转换");
	cout << "转换后:" << wc << endl;
	string s(1, i + '0');
	display("string", "构造方法string(size_t n,char c)");
	cout << "转换后:" << s << endl;
	string s1;
	s1.push_back(i + '0');
	display("string", "push_back");
	cout << "转换后:" << s1 << endl;
	const char* cc = &c;
	display("const char*", "隐式转换");
	cout << "转换后:" << *cc << endl;
	char* c_c = &c;
	display("char*", "隐式转换");
	cout << "转换后:" << *c_c << endl;

}

void unsignedshortint2other(unsigned short int i)
{
	char c = i + '0';
	display("int", "+'0'");
	cout << "转换后:" << c << endl;
	unsigned char uc = i + '0';
	display("unsigned char", "隐式转换");
	cout << "转换后:" << uc << endl;
	signed char sc = i + '0';
	display("signed char", "隐式转换");
	cout << "转换后:" << sc << endl;
	int ui = i;
	display("int", "隐式转换");
	cout << "转换后:" << ui << endl;
	unsigned int si = i;
	display("unsigned int", "隐式转换");
	cout << "转换后:" << si << endl;
	short int usi = i;
	display("short int", "隐式转换");
	cout << "转换后:" << usi << endl;
	signed int s_i = i;
	display("signed int", "隐式转换");
	cout << "转换后:" << s_i << endl;
	long int li = i;
	display("long int", "隐式转换");
	cout << "转换后:" << li << endl;
	signed long int sli = i;
	display("signed long int", "隐式转换");
	cout << "转换后:" << sli << endl;
	unsigned long int uli = i;
	display("unsigned long int", "隐式转换");
	cout << "转换后:" << uli << endl;
	float f = i;
	display("float", "隐式转换");
	cout << "转换后:" << f << endl;
	double d = i;
	display("double", "隐式转换");
	cout << "转换后:" << d << endl;
	long double ld = i;
	display("long double", "隐式转换");
	cout << "转换后:" << ld << endl;
	wchar_t wc = i;
	display("wchar_t", "隐式转换");
	cout << "转换后:" << wc << endl;
	string s(1, i + '0');
	display("string", "构造方法string(size_t n,char c)");
	cout << "转换后:" << s << endl;
	string s1;
	s1.push_back(i + '0');
	display("string", "push_back");
	cout << "转换后:" << s1 << endl;
	const char* cc = &c;
	display("const char*", "隐式转换");
	cout << "转换后:" << *cc << endl;
	char* c_c = &c;
	display("char*", "隐式转换");
	cout << "转换后:" << *c_c << endl;
}

void signedshortint2other(signed short int i)
{
	char c = i + '0';
	display("int", "+'0'");
	cout << "转换后:" << c << endl;
	unsigned char uc = i + '0';
	display("unsigned char", "隐式转换");
	cout << "转换后:" << uc << endl;
	signed char sc = i + '0';
	display("signed char", "隐式转换");
	cout << "转换后:" << sc << endl;
	int ui = i;
	display("int", "隐式转换");
	cout << "转换后:" << ui << endl;
	unsigned int si = i;
	display("unsigned int", "隐式转换");
	cout << "转换后:" << si << endl;
	short int usi = i;
	display("short int", "隐式转换");
	cout << "转换后:" << usi << endl;
	signed int s_i = i;
	display("signed int", "隐式转换");
	cout << "转换后:" << s_i << endl;
	long int li = i;
	display("long int", "隐式转换");
	cout << "转换后:" << li << endl;
	signed long int sli = i;
	display("signed long int", "隐式转换");
	cout << "转换后:" << sli << endl;
	unsigned long int uli = i;
	display("unsigned long int", "隐式转换");
	cout << "转换后:" << uli << endl;
	float f = i;
	display("float", "隐式转换");
	cout << "转换后:" << f << endl;
	double d = i;
	display("double", "隐式转换");
	cout << "转换后:" << d << endl;
	long double ld = i;
	display("long double", "隐式转换");
	cout << "转换后:" << ld << endl;
	wchar_t wc = i;
	display("wchar_t", "隐式转换");
	cout << "转换后:" << wc << endl;
	string s(1, i + '0');
	display("string", "构造方法string(size_t n,char c)");
	cout << "转换后:" << s << endl;
	string s1;
	s1.push_back(i + '0');
	display("string", "push_back");
	cout << "转换后:" << s1 << endl;
	const char* cc = &c;
	display("const char*", "隐式转换");
	cout << "转换后:" << *cc << endl;
	char* c_c = &c;
	display("char*", "隐式转换");
	cout << "转换后:" << *c_c << endl;
}

void float2int(float f)
{
	int i = f;
	display("int", "隐式转换");
	cout << "转换后:" << i << endl;
	unsigned int ui = f;
	display("unsigned int", "隐式转换");
	cout << "转换后:" << ui << endl;
	short int si = (short int)f;
	display("short int", "显式转换");
	cout << "转换后:" << si << endl;
	signed int s_i = f;
	display("signed int", "隐式转换");
	cout << "转换后:" << s_i << endl;
	long int li = (long int)f;
	display("long int", "显式转换");
	cout << "转换后:" << li << endl;
	signed long int sli = f;
	display("signed long int", "隐式转换");
	cout << "转换后:" << sli << endl;
	unsigned long int uli = f;
	display("unsigned long int", "隐式转换");
	cout << "转换后:" << uli << endl;
}

void string2other(string s)
{
	const char * cc; 
	cc = s.c_str();
	display("const char *", "使用方法c_str");
	cout << "转换后:" << cc << endl;
	char * c = const_cast<char*>(cc);
	display("char *", "c_str转为const char *,再使用const_cast<char*>()转为char *");
	cout << "转换后:" << c << endl;
}

void constchar2other(const char* cc)
{
	string s = cc;
	display("string", "隐式转换");
	cout << "转换后:" << s << endl;
	char * c = const_cast<char*>(cc);
	display("char *", "const_cast<char*>()");
	cout << "转换后:" << c << endl;
	char ca[10];
	display("char[]", "strncpy_s()");
	strncpy_s(ca, cc, 10);
	cout << "转换后:" << ca << endl;
}

void char_2other(char* c)
{
	string s = c;
	display("string", "隐式转换");
	cout << "转换后:" << s << endl;
	const char * cc = c;
	display("const char *", "隐式转换");
	cout << "转换后:" << cc << endl;
	char ca[10];
	display("char[]", "strncpy_s()");
	strncpy_s(ca, c, 10);
	cout << "转换后:" << ca << endl;
}

int main()
{
	//char2other('n');
	unsignedchar2other('n');
	//signedchar2other('n');
	//signedchar2other('n');
	//int2other(9);
	//unsignedint2other(9);
	//float2int(9.3);
	//string2other("abcd");
	//const char* cc = "abcd";
	//constchar2other("abcd");
	//char_2other("sdfesgrf");

	//问题1  ch会变
	//string s("nkjsf");
	//const char* ch = s.c_str();
	//cout << ch << endl;
	//s = "efefd";
	//cout << ch << endl;
	//问题2  char2other函数输出cc没有烫 unsignedchar2other输出cc有烫
	//char c = 'n';
	//const char *cc = &c;
	//cout << cc << endl;
}

更多数据结构与算法实现:数据结构(严蔚敏版)与算法的实现(含全部代码)

有问题请下方评论,转载请注明出处,并附有原文链接,谢谢!如有侵权,请及时联系。

网站文章

  • glFlush 和glSwapBuffer

    1 glFlush就是强制刷新吧,要知道OPENGL是使用一条渲染管线线性处理命令的,一般情况下,我们提交给OPENGL的指令并不是马上送到驱动程序里执行的,而是放到一个缓冲区里面,等这个缓冲区满了再一次过发到驱动程序里执行;很多时候只有几条指令是填充不满那个缓冲区的,这就是说这些指令根本没有被发送到驱动里,所以我们要调用glFlush来强制把这些指令送到驱动里进行处理。 2 glutSwap

    2024-02-01 02:42:40
  • 网络编程之Telnet简单远程登录协议

    网络编程之Telnet简单远程登录协议

    这里不讲解telnet协议的实现原理,主要用于学习telnet实际的编写方式。 使用的网络协议:tcp/ip telnet协议 编程语言:C/C++ 库:socket套接字 基于Windows的tel...

    2024-02-01 02:42:33
  • 创建单链表中出现的一些经典错误(typedef关键字与指针)

    创建单链表中出现的一些经典错误(typedef关键字与指针)

    本文记录的是本人在单链表学习及实现过程中的个人理解和遇到的一些错误,不严谨之处欢迎批评指正。

    2024-02-01 02:42:26
  • Linux Shell 进阶 - Linux Shell进阶学习教程 - Linux Shell练习 - HPC基础 - 源码设计师

    Linux Shell 进阶 - Linux Shell进阶学习教程 - Linux Shell练习 - HPC基础 - 源码设计师

    Linux Shell 进阶 - Linux Shell进阶学习教程 - Linux Shell练习 - HPC基础 - 源码设计师 Linux Shell进阶学习教程 - Linux Shell练习...

    2024-02-01 02:41:57
  • mac OS锁定 解锁文件

    mac OS锁定 解锁文件

    mac OS锁定 解锁文件

    2024-02-01 02:41:54
  • java基础——方法

    方法 /** * 1.什么是方法? * 方法就是把一堆需要反复执行的代码封装起来,如果程序需要执行这段代码,直接调用方法名即可。 * 就是类似于一个榨汁机, * 材料:水果 * 产出物:果汁 * * ...

    2024-02-01 02:41:51
  • 获取浏览器语言

    获取浏览器语言(navigator.language || navigator.browserLanguage).toLowerCase()根据浏览器语言切换语言//根据浏览器语言切换语言functi...

    2024-02-01 02:41:23
  • Tensorflow深度学习之-激活函数选择与使用介绍

    Tensorflow深度学习之-激活函数选择与使用介绍

    激活函数都有一定的使用场景,ReLU的流行只是在大部分的场景下都适用,具体要选择哪种激活函数,要根据你自己的实际应用来作决策。如果你不确定你要用什么,ReLU不会让你失望。在使用ReLU时,ReLU和leaky ReLU任取一个即可,也可以都尝试一下,哪一个能取得最佳结果。

    2024-02-01 02:41:16
  • ActiveMQ初步安装

    ActiveMQ初步安装

    一、官网下载 ActiveMQ官网:http://activemq.apache.org/ 安装ActiveMQ的前提是已经安装好了JAVA JDK环境。 PS:我这里下载的是经典版 下载完之后将它放...

    2024-02-01 02:41:09
  • spring boot 、mybatis-plus、shiro整合入门教程(二)——mybatis-plus常用操作

    spring boot 、mybatis-plus、shiro整合入门教程(二)——mybatis-plus常用操作

    接续上一篇,spring boot 、mybatis-plus、shiro整合入门教程(一)——mybatis-plus代码生成器项目中的数据库表设计如下:菜单管理页面功能:新增、修改、删除、查询新增代码如下:SysMenuController类的代码如下:@Resource private SysMenuServiceImpl sysMenuService; /*...

    2024-02-01 02:41:00