0816,特殊数据成员/成员函数,对象组织,delete/new,单例模式

2024-08-29 00:12

本文主要是介绍0816,特殊数据成员/成员函数,对象组织,delete/new,单例模式,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

01 特殊的数据成员 (是我写作业不看题目

1,常量数据成员
加上const 的数据成员,加上之后只能在声明和初始化队列中进行初始化,初始化之后不能进行赋值操作

2,引用数据数据成员
用引用方式创建的数据成员
引用数据成员需要在初始化列表中进行初始化
需要绑定一个已经存在的,在引用成员的生命周期内始终有效的变量(对象

3,对象成员
一个类的对象是其他类的数据成员
coution:
初始化列表写对象,不写类名,不能在声明对象成员时直接用有参构造创建
如果在初始化列表中没有显示的初始化对象成员,编译器回自动调用对象成员的默认无参构造或者所有参数都有默认值的有参
堆空间资源回收顺序(类的对象-->对象成员)

4,静态数据成员
加上static修饰的数据成员
存储在全局/静态区,不占据对象的存储空间,静态数据成员被整个类的所有对象共享
规则:
4.1 private 的静态数据成员无法在类之外直接访问
4.2 初始化必须放在类外(一般紧接类定义
4.3 初始化时不能在前面+static,要加类名+作用域限定符
4.4 多条初始化顺序和声明顺序一致
4.5 对象访问 & 类名::访问

001const.cc

#include <iostream>
using std::cout;
using std::endl;class Point{
public:Point()//只能用 这种 严格意义的初始化/* :_ix(0),_iy(0) */{cout<<"Point()"<<endl;}Point(int x,int y=1):_ix(x),_iy(y) //const int _ix=x;//can't _ix=x;{cout<<"Point(int ,int)"<<endl;}Point(const Point & p):_ix(p._ix),_iy(p._iy){cout<<"Point(Point &)"<<endl;}void print(){ cout<<_ix<<"\t\t"<<_iy<<endl; }
private:const  int _ix=1;const  int _iy=1;//备胎中的备胎//只能算声明/* const  int _ix; *//* const  int _iy; */
};void test(){Point pt1;Point pt2(5);Point pt(1,2);Point pt3(pt1);/* pt3=pt2; *///声明了常量数据成员,不能进行常规意义的赋值操作pt1.print();
}int main(void)
{test();return 0;
}

002refmember.cc

#include <iostream>
using std::cout;
using std::endl;int gNum=100;
//只能绑定一个已经存在,在引用期间成员的生命周期内
//始终有效的变量(对象
class Point{
public:Point():_ix(0),_iy(0),_ref(_ix){cout<<"Point()"<<endl;}Point(int x,int y=1):_ix(x),_iy(y) //const int _ix=x;/* ,_ref(_ix) */{cout<<"Point(int ,int)"<<endl;}/* Point(int x,int y,int z) *//*     :_ix(x),_iy(y) //const int _ix=x; *//*     ,_ref(z) *//*     {cout<<"Point(int ,int,int)"<<endl;} */Point(const Point & p):_ix(p._ix),_iy(p._iy),_ref(p._ref){cout<<"Point(Point &)"<<endl;}void print(){ cout<<_ix<<"\t\t"<<_iy<<"\t\t"<<_ref<<endl; }
private:int _ix;int _iy;/* int & _ref; */int & _ref=gNum;/* int & _ref=_iy; */
};void test(){Point pt1;/* Point pt2(5,6,7); //7生命周期?一个牛逼的数字 */Point pt2(pt1);Point pt3(1,2);Point pt4(9);/* pt3=pt2; *///声明了常量数据成员,不能进行常规意义的赋值操作pt1.print();pt2.print();pt3.print();pt4.print();
}int main(void)
{test();return 0;
}

 003object.cc

#include <iostream>
using std::cout;
using std::endl;class Point{
public:Point():_ix(0),_iy(0){cout<<"Point()"<<endl;}Point(int x=1,int y=1):_ix(x),_iy(y) //const int _ix=x;{cout<<"Point(int ,int)"<<endl;}Point(const Point & p):_ix(p._ix),_iy(p._iy){cout<<"Point(Point &)"<<endl;}~Point(){cout<<"~Point()"<<endl;}void print(){ cout<<_ix<<" "<<_iy; }
private:int _ix;int _iy;
};class Line{
public:Line(int x1,int y1,int x2,int y2):_pt1(x1,y1),_pt2(x2,y2)/* :_pt1(),_pt2() *///搞不懂啊啊啊,为撒不初始化的不行喵,创建worning,打印error//LIne的构造函数的初始化列表中//需要显示调用point的构造完成对象成员的初始化//如果没有,编译器自动调用POINT的无参构造//活着所有参数都有默认值的有参构造{cout<<"Line(int*4)"<<endl;}~Line(){cout<<"~line"<<endl;}void printLine(){_pt1.print();cout<<"---->";_pt2.print();cout<<endl;}
private:Point _pt1;Point _pt2;
};void test(){Line l(1,2,3,4);l.printLine();/* Line l1(); *//* l1.printLine(); */
}int main(void)
{test();return 0;
}

04_static_member.cc 

#include <iostream>
#include <string.h>
using std::cout;
using std::endl;class Computer{
public:/* void init(const char* brand,int price){ *//*     strcpy(_brand,brand); *//*     _price=price; *//* } */void printBrandPrice(){cout<<_brand<<"\t";cout<<_price<<endl;}static int get_totalprice(){return _totalprice;}
//----------------------------//
/* private: */Computer(const char* brand,int price): _brand(new char[strlen(brand)+1]()), _price(price){strcpy(_brand,brand);// 否则没有赋值喵,不输出_totalprice+=_price;cout<<_brand<<"\t\t"<<"Computer(char* int)"<<endl;}Computer(const Computer & c): _brand(new char[strlen(c._brand)+1]()), _price(c._price){strcpy(_brand,c._brand);// 否则没有赋值喵,不输出_totalprice+=_price;cout<<"Computer(cosnt Computer &)"<<endl;}Computer & operator=(const Computer & c){if(this!=&c){delete [] _brand;_brand=new char[strlen(c._brand)+1]();strcpy(_brand,c._brand);_price=c._price;_totalprice+=_price;}return *this;}
//----------------------------//~Computer(){cout<<_brand<<"\t\t";if(_brand){delete  _brand;  //coution_brand=nullptr;   //加上,信任行为喵_totalprice-=_price;}cout<<"~Computer"<<endl;}
private:char* _brand;int _price;static int  _totalprice; 
};
int Computer::_totalprice=0; //----------------------------//
void test(){cout<<sizeof(Computer)<<endl;cout<<Computer::get_totalprice()<<endl;Computer p1("xixi",66);cout<<p1.get_totalprice()<<endl;Computer p2("paxi",66);cout<<p1.get_totalprice()<<endl;
}
int main(void)
{test();return 0;
}

05_constMember.cc

#include <iostream>
#include <string.h>
using std::cout;
using std::endl;class Computer{
public:void init(int price)/*const*/{_price=price;}void printBrandPrice()const{cout<<_brand<<"\t";cout<<_price<<"\tconst_print"<<endl;}
//----------------------------//
/* private: */Computer(const char* brand,int price): _brand(new char[strlen(brand)+1]()), _price(price){strcpy(_brand,brand);// 否则没有赋值喵,不输出cout<<_brand<<"\t\t"<<"Computer(char* int)"<<endl;}Computer(const Computer & c): _brand(new char[strlen(c._brand)+1]()), _price(c._price){strcpy(_brand,c._brand);// 否则没有赋值喵,不输出cout<<"Computer(cosnt Computer &)"<<endl;}Computer & operator=(const Computer & c){if(this!=&c){delete [] _brand;_brand=new char[strlen(c._brand)+1]();strcpy(_brand,c._brand);_price=c._price;}return *this;}
//----------------------------//~Computer(){cout<<_brand<<"\t\t";if(_brand){delete  _brand;  //coution_brand=nullptr;   //加上,信任行为喵}cout<<"~Computer"<<endl;}
private:char* _brand;int _price;
};//----------------------------//
void test(){cout<<sizeof(Computer)<<endl;Computer p1("xixi",66);p1.init(7888);//不能修改对象的数据成员p1.printBrandPrice();cout<<endl;const Computer p2("paxi",66);p2.printBrandPrice();/* p2.init(7888); */cout<<endl;
}
int main(void)
{test();return 0;
}

06_constfuction.cc

#include <iostream>
#include <string.h>
using std::cout;
using std::endl;class Computer{
public:void init(int price)/*const*/{_price=price;}void printBrandPrice(const Computer & c)const{/* for(int i=0;i<strlen(c._brand)+1;i++){ *//*     _brand[i]=c._brand[i]; *//* } *///尽量避免cout<<_brand<<"\t";cout<<_price<<"\tconst_print"<<endl;}//----------------------------///* private: */Computer(const char* brand,int price): _brand(new char[strlen(brand)+1]()), _price(price){strcpy(_brand,brand);// 否则没有赋值喵,不输出cout<<_brand<<"\t\t"<<"Computer(char* int)"<<endl;}Computer(const Computer & c): _brand(new char[strlen(c._brand)+1]()), _price(c._price){strcpy(_brand,c._brand);// 否则没有赋值喵,不输出cout<<"Computer(cosnt Computer &)"<<endl;}Computer & operator=(const Computer & c){if(this!=&c){delete [] _brand;_brand=new char[strlen(c._brand)+1]();/* strcpy(_brand,c._brand); */_price=c._price;}return *this;}//----------------------------//~Computer(){cout<<_brand<<"\t\t";if(_brand){delete  _brand;  //coution_brand=nullptr;   //加上,信任行为喵}cout<<"~Computer"<<endl;}
private:/* const char* _brand;//+brand[]也不行,只读变量不可赋值 */char* _brand;int _price;
};//----------------------------//
void test(){Computer p1("xixi",66);Computer p2("kaixin",66);p1.printBrandPrice(p2);cout<<endl;
}
int main(void)
{test();return 0;
}

07_PointArray.cc

#include <iostream>
using std::cout;
using std::endl;class Point{
public:Point():_ix(0),_iy(0){cout<<"Point()"<<endl;}Point(int x/*=1*/,int y=1):_ix(x),_iy(y) //const int _ix=x;{cout<<"Point(int ,int)"<<endl;}Point(const Point & p):_ix(p._ix),_iy(p._iy){cout<<"Point(Point &)"<<endl;}~Point(){cout<<"~Point()"<<endl;}Point & operator=(const Point & p){_ix=p._ix;_iy=p._iy;return *this;}void print(){ cout<<_ix<<" "<<_iy<<endl; }
private:int _ix;int _iy;
};void test(){Point* p1=new Point(3,4);p1->print();(*p1).print();delete p1;//()确保进行了初始化,初始化为相应类信息的默认值int *p=new int();cout<<*p<<endl;delete p;//Point 类型的默认值是无参构造初始化的Point对象Point* p2=new Point();//调用模糊p2->print();delete p2;//------------------------------//cout<<endl;Point p4(7,5);Point p3(3,5);Point p6(6,5);Point arr[3]={p4,p3,p6};//Point(const Point &)cout<<&p4<<endl;cout<<arr<<endl;cout<<endl;Point ar1[2]={Point(1,2),Point(3,4)};ar1[0].print();(ar1+1)->print();cout<<endl;Point ar2[2]={{2,2},{5,5}};
}int main(void)
{test();return 0;
}

08_Student.cc

#include <iostream>
#include <string.h>
using std::cout;
using std::endl;class Student
{
public:Student(int id, const char * name): _id(id), _name(new char[strlen(name) + 1]()){strcpy(_name, name);cout << "Student()" << endl;}~Student(){if(_name){delete [] _name;_name = nullptr;}}//------------------------------//void operator delete(void * pointer){cout<<"operator delete"<<endl;free(pointer);}void* operator new(size_t sz){cout<<"operator new "<<endl;void* ret=malloc(sz);return ret;}//------------------------------//void print() const{cout << "id:" << _id << "\t"<< "name:" << _name << endl;}
private:int _id;char * _name;
};//------------------------------//
void test(){Student * s=new Student(3,"xixi");s->print();delete s;
}int main(void)
{test();return 0;
}

09_HeapStudent.cc

#include <iostream>
#include <string.h>
using std::cout;
using std::endl;class Student
{
public:Student(int id, const char * name): _id(id), _name(new char[strlen(name) + 1]()){strcpy(_name, name);cout << "Student()" << endl;}~Student(){if(_name){delete [] _name;_name = nullptr;}}//------------------------------//void operator delete(void * pointer){cout<<"operator delete"<<endl;free(pointer);}void* operator new(size_t sz){cout<<"operator new "<<endl;void* ret=malloc(sz);return ret;}void destroy(){delete this;}//------------------------------//void print() const{cout << "id:" << _id << "\t"<< "name:" << _name << endl;}
private:int _id;char * _name;
};//------------------------------//
void test(){Student * s=new Student(3,"xixi");s->print();s->destroy();/* delete s; */
}int main(void)
{test();return 0;
}

10_StackStudent.cc

#include <iostream>
#include <string.h>
using std::cout;
using std::endl;class Student
{
public:Student(int id, const char * name): _id(id), _name(new char[strlen(name) + 1]()){strcpy(_name, name);cout << "Student()" << endl;}~Student(){if(_name){delete [] _name;_name = nullptr;}}void print() const{cout << "id:" << _id << "\t"<< "name:" << _name << endl;}
private://------------------------------//void operator delete(void * pointer){cout<<"operator delete"<<endl;free(pointer);}void* operator new(size_t sz){cout<<"operator new "<<endl;void* ret=malloc(sz);return ret;}void destroy(){delete this;}//------------------------------//
private:int _id;char * _name;
};//------------------------------//
void test(){/* Student * s=new Student(3,"xixi"); */Student s(3,"xix");s.print();/* s.destroy(); *//* delete s; */
}int main(void)
{test();return 0;
}

static_single.cc

#include <iostream>
using std::cout;
using std::endl;class Point{
public:Point():_ix(0),_iy(0){cout<<"Point()"<<endl;}/* Point(const Point & p) *//*     :_ix(p._ix),_iy(p._iy) *//*     {cout<<"Point(Point &)"<<endl;} *///删除  拷贝构造效果更好?????//删除  赋值构造效果更好?????void print(){ cout<<_ix<<"\t\t"<<_iy<<endl; }static Point & getInstance(){static Point pt(2,8);//单例模式,只能初始化一次return pt;}//不是静态成员函数???
private:Point(int x,int y=1):_ix(x),_iy(y){cout<<"Point(int ,int)"<<endl;}//构造  私有~Point(){cout<<"~Point()"<<endl;}//析构  私有(四大金刚全部干掉喵
private:int _ix;int _iy;
};void test(){Point & pt1=Point::getInstance();Point & pt2=Point::getInstance();cout<<&pt1<<endl;cout<<&pt2<<endl;
}int main(void)
{test();return 0;
}

heap_single.cc 

#include <iostream>
using std::cout;
using std::endl;//堆上创建单例对象
class Point{
public:static Point * getInstance(){if(_pInstance==nullptr){_pInstance=new Point(1,2);} return _pInstance;}static void destroy(){if(_pInstance){delete _pInstance;_pInstance=nullptr;}cout<<"<<<delete heap"<<endl;}//C++11之后可以将成员函数从类中删除Point(Point & rhs)=delete;Point & operator=(const Point & rhs)=delete;void init(int x,int y){_ix=x;_iy=y;}//初始化和赋值分开void print(){ cout<<_ix<<"\t\t"<<_iy<<endl; }
private:Point():_ix(0),_iy(0){cout<<"Point()"<<endl;}Point(int x,int y):_ix(x),_iy(y) //const int _ix=x;{cout<<"Point(int ,int)"<<endl;}~Point(){cout<<"~point()"<<endl;}
private:int _ix;int _iy;static Point* _pInstance;//定义一个指针保存第一次创建的对象
};
Point * Point::_pInstance=nullptr;
//初始化void test(){//使用规范,避免多个指针拥有单例对象的管理权Point::getInstance()->print();Point::getInstance()->init(21,13);Point::getInstance()->print();Point::getInstance()->init(23,231);Point::getInstance()->print();Point::destroy();Point::destroy();Point::destroy();//多次执行也不会有double free的问题Point::getInstance()->print();Point::destroy();
}int main(void)
{test();return 0;
}

06 作业

01,特殊的成员函数有哪几种?各自的特点是什么? (坏,答了一个特殊的数据成员

1,static成员函数

0.1 静态成员函数不依赖于某一对象
0.2 静态成员函数可以通过对象调用,但更加常见的方式是通过类名加上作用域限定符调用
0.3 静态成员函数没有this指针
0.4 静态成员函数中无法直接使用成员名访问非静态的成员,只能访问静态数据成员或调用静态成员(因为没有this指针),但是非静态的成员函数可以访问静态成员
0.5 构造/析构/赋值运算符/拷贝构造比较特殊,可以在静态成员函数中调用(这四个函数不能设置为静态成员函数,他们会访问所有的成员对象,但是静态成员函数没有this指针)

2,const成员函数

0.1 cosnt 成员函数中,不能修改对象的数据成员
0.2 当编译器发现该函数是const成员函数时,会自动将this指针设置为双重const限定的指针

const 对象与const 成员函数的规则:

当类中有const成员函数和非const成员函数重载时,const对象会调用const成员函数,非const对象会调用非const成员函数
当类中只有一个const成员函数时,无论const对象还是非const对象都可以调用这个版本
当类中只有一个非const成员函数时,const对象就不能调用非const版本

总结:如果一个成员函数中确定不会修改数据成员,就把它定义为const成员函数

02,写出以下程序运行的结果。( )

class Sample 
{
public:Sample();void Display();
private:int i;static int k;
};Sample::Sample() 
{i=0;k++;
}void Sample::Display() 
{cout << "i=" << i << ",k=" << k << endl;
}int Sample::k=0;int main( ) 
{Sample a, b;a.Display();b.Display();return 0;
}

i=0,k=1(2)坏

i=0,k=2 

03,写出下面程序的结果:  11

#include <iostream>
using std::cout;
using std::endl;int i = 1;class Test
{
public:Test():_first(i++) //1  2,_second(i++)//2  3,_third(i++)//3  4,_fourth(_third)//3{_third = i;//4   _foruth=4}void print(){  cout << "result : " << _first + _second + _third + _fourth << endl;//1 2 4 4 =11}
private:int _first;int _second;int _third;int &_fourth;
};int main()
{Test test;test.print();return 0;
}

04,写出以下程序运行的结果。

#include <iostream>
#include <math.h>
using std::cout;
using std::endl;class Point	
{
public:Point(int xx = 0, int yy = 0) {X = xx;Y = yy;cout << "point构造函数被调用" << endl;}Point(Point &p);int GetX() {return X;}int GetY() {return Y;}private:int X,Y;
};Point::Point(Point &p)	
{X = p.X;Y = p.Y;cout << "X = " << X << " Y=" << Y << "Point拷贝构造函数被调用" << endl;
}class Distance	
{
public:	Distance(Point xp1, Point xp2);double GetDis(){return dist;}
private:	Point p1,p2;double dist;	
};//拷贝一次
Distance::Distance(Point xp1, Point xp2)
: p1(xp1)//拷贝一次
, p2(xp2)
{cout << "Distance构造函数被调用" << endl;double x = double(p1.GetX() - p2.GetX());double y = double(p1.GetY() - p2.GetY());dist = sqrt(x * x + y * y);
}int main()
{//point构造函数被调用//point构造函数被调用Point myp1(1,1), myp2(4,5);//X=1,Y=1,Point拷贝构造函数被调用//X=4,Y=5,Point拷贝构造函数被调用//X=1,Y=1,Point拷贝构造函数被调用//X=4,Y=5,Point拷贝构造函数被调用Distance myd(myp1, myp2);//Distance构造函数被调用cout << "The distance is:" ;//The distance is:distcout << myd.GetDis() << endl;return 0;
}

point构造函数被调用
point构造函数被调用
X = 4 Y=5Point拷贝构造函数被调用
X = 1 Y=1Point拷贝构造函数被调用
X = 1 Y=1Point拷贝构造函数被调用
X = 4 Y=5Point拷贝构造函数被调用
Distance构造函数被调用
The distance is:5  

05,写出以下程序运行的结果。   122444

#include <iostream>
using std::cout;
using std::endl;class MyClass
{
public:MyClass(int i = 0){cout << i;}MyClass(const MyClass &x){cout << 2;}MyClass &operator=(const MyClass &x){cout << 3;return *this;}~MyClass(){cout << 4;}
};
int main()
{MyClass obj1(1), obj2(2);//12MyClass obj3 = obj1;//==Myclass obj3(obj1);//32444return 0;
}

06,不考虑任何编译器优化(如:NRVO),下述代码的第10#会发生-fno-elide-constructors 编译时消除优化的影响

#include <iostream>
using std::cout;
using std::endl;class B
{
public:B(){cout << "B()" << endl;}~B(){cout << "~B()" << endl;}B(const B &rhs){cout << "B(const B&)" << endl;}B &operator=(const B &rhs){cout << "B &operator=(const B &s)" << endl;return  *this;}
};B func(const B &rhs)//cp  不是喵是赋值
{cout << "B func(const B &)" << endl;return rhs;
}int main(int argc, char **argv)
{B b1,b2;b2=func(b1);//10#//B func(const B &)//B(const B&)//B &operator=(const B &s)return 0;
}

B func(const B &)
B(const B&)
B &operator=(const B &s) 

07,new表达式和delete表达式的底层实现是什么?

1,对于自定义类型而言

使用new表达式的三个步骤:
1,调用operator new标准库函数申请未类型化的空间
2,在该空间上调用该类型的构造函数初始化对象
3,返回指向该对象的相应类型的指针

使用delete表达式···
1,调用析构函数,回收数据成员申请的资源(堆空间)
2,调用operator delete库函数回收本对象所在的空间

对于内置类型而言,则没有以上构造函数和析构函数执行的步骤

08,实现单例的Point类(将单例对象创建在堆上)

heap_single.cc 

09,实现一个单例的Computer类,包含品牌和价格信息。

#include <iostream>
#include <string.h>
using std::cout;
using std::endl;class Computer{
public:static Computer * get(){if(!_pp){_pp=new Computer("xixi",520); }return _pp; } /* void* operator new(size_t sz){ *//*     void * ret=malloc(sz); *//*     return ret; *//* } *//* void operator delete(void * p){ *//*     free(p); *//* } */static void destory(){if(_pp){delete _pp;_pp=nullptr;}cout<<"<<<< destory"<<endl;}Computer(Computer & c)=delete;Computer & operator=(const Computer & c)=delete;void init(const char* brand,int price){strcpy(_brand,brand);_price=price;}void printBrandPrice(){cout<<_brand<<"\t";cout<<_price<<endl;}
private:Computer(const char* brand,int price): _brand(new char[strlen(brand)+1]()), _price(price){strcpy(_brand,brand);// 否则没有赋值喵,不输出cout<<_brand<<"\t\t"<<"Computer"<<endl;}~Computer(){cout<<_brand<<"\t\t";if(_brand){delete  _brand;  //coution_brand=nullptr;   //加上,信任行为喵}cout<<"~Computer"<<endl;}
private:char* _brand;int _price;static Computer * _pp; 
};
Computer*Computer::_pp=nullptr;void test(){Computer::get()->printBrandPrice();Computer::get()->init("jiajia",7758258);Computer::get()->printBrandPrice();Computer::get()->init("yueyue",51930);Computer::get()->printBrandPrice();Computer::destory();Computer::destory();Computer::destory();
}
void test01(){
}
int main(void)
{test();test01();return 0;
}

这篇关于0816,特殊数据成员/成员函数,对象组织,delete/new,单例模式的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



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

相关文章

SpringBoot使用GZIP压缩反回数据问题

《SpringBoot使用GZIP压缩反回数据问题》:本文主要介绍SpringBoot使用GZIP压缩反回数据问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录SpringBoot使用GZIP压缩反回数据1、初识gzip2、gzip是什么,可以干什么?3、Spr

Python中判断对象是否为空的方法

《Python中判断对象是否为空的方法》在Python开发中,判断对象是否为“空”是高频操作,但看似简单的需求却暗藏玄机,从None到空容器,从零值到自定义对象的“假值”状态,不同场景下的“空”需要精... 目录一、python中的“空”值体系二、精准判定方法对比三、常见误区解析四、进阶处理技巧五、性能优化

SpringBoot集成Milvus实现数据增删改查功能

《SpringBoot集成Milvus实现数据增删改查功能》milvus支持的语言比较多,支持python,Java,Go,node等开发语言,本文主要介绍如何使用Java语言,采用springboo... 目录1、Milvus基本概念2、添加maven依赖3、配置yml文件4、创建MilvusClient

shell编程之函数与数组的使用详解

《shell编程之函数与数组的使用详解》:本文主要介绍shell编程之函数与数组的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录shell函数函数的用法俩个数求和系统资源监控并报警函数函数变量的作用范围函数的参数递归函数shell数组获取数组的长度读取某下的

SpringValidation数据校验之约束注解与分组校验方式

《SpringValidation数据校验之约束注解与分组校验方式》本文将深入探讨SpringValidation的核心功能,帮助开发者掌握约束注解的使用技巧和分组校验的高级应用,从而构建更加健壮和可... 目录引言一、Spring Validation基础架构1.1 jsR-380标准与Spring整合1

Python中的魔术方法__new__详解

《Python中的魔术方法__new__详解》:本文主要介绍Python中的魔术方法__new__的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、核心意义与机制1.1 构造过程原理1.2 与 __init__ 对比二、核心功能解析2.1 核心能力2.2

MySQL高级查询之JOIN、子查询、窗口函数实际案例

《MySQL高级查询之JOIN、子查询、窗口函数实际案例》:本文主要介绍MySQL高级查询之JOIN、子查询、窗口函数实际案例的相关资料,JOIN用于多表关联查询,子查询用于数据筛选和过滤,窗口函... 目录前言1. JOIN(连接查询)1.1 内连接(INNER JOIN)1.2 左连接(LEFT JOI

MySQL 中查询 VARCHAR 类型 JSON 数据的问题记录

《MySQL中查询VARCHAR类型JSON数据的问题记录》在数据库设计中,有时我们会将JSON数据存储在VARCHAR或TEXT类型字段中,本文将详细介绍如何在MySQL中有效查询存储为V... 目录一、问题背景二、mysql jsON 函数2.1 常用 JSON 函数三、查询示例3.1 基本查询3.2

SpringBatch数据写入实现

《SpringBatch数据写入实现》SpringBatch通过ItemWriter接口及其丰富的实现,提供了强大的数据写入能力,本文主要介绍了SpringBatch数据写入实现,具有一定的参考价值,... 目录python引言一、ItemWriter核心概念二、数据库写入实现三、文件写入实现四、多目标写入

MySQL中FIND_IN_SET函数与INSTR函数用法解析

《MySQL中FIND_IN_SET函数与INSTR函数用法解析》:本文主要介绍MySQL中FIND_IN_SET函数与INSTR函数用法解析,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一... 目录一、功能定义与语法1、FIND_IN_SET函数2、INSTR函数二、本质区别对比三、实际场景案例分