类和对象(2)

news2024/9/27 9:12:57

在这里插入图片描述

文章目录

  • 🎯引言
  • 👓类和对象(2)
    • 1.类的默认成员函数
    • 2.构造函数
      • 2.1构造函数概念
    • 3.析构函数
      • 3.1. **析构函数的定义**
      • 3.2. **析构函数的特点**
    • 4.拷贝构造函数
      • 4.1. **拷贝构造函数的定义**
    • 5.赋值运算符重载
      • 5.1运算符重载
      • 5.2赋值运算符重载
      • 5.3日期类的实现
  • 🥇结语

🎯引言

在C++中,类的成员函数可以由程序员自行定义,但编译器在某些情况下会自动为类生成一些特殊的默认成员函数。这些函数包括构造函数、析构函数、拷贝构造函数、赋值运算符等。了解这些默认成员函数的生成规则及其行为,对于编写高效、健壮的C++代码至关重要。本文将深入探讨C++中的默认成员函数,分析它们的用途、行为以及在实际开发中如何合理利用和控制这些函数。

👓类和对象(2)

1.类的默认成员函数

在C++中,当你定义一个类而没有提供某些成员函数的实现时,编译器会自动为该类生成一些默认的成员函数。这些默认的成员函数包括以下几种:

1.1初始化和清理:

构造函数主要完成初始化工作

析构函数主要完成清理工作

1.2拷贝复制

拷贝构造是使用同类对象初始化创建对象

赋值重载主要是把一个对象赋值给另一个对象

1.3取地址重载

主要是普通对象和const对象取地址,这两个很少会自己实现(可自行了解)

2.构造函数

2.1构造函数概念

什么是构造函数?

构造函数是一个特殊的成员函数,用于初始化对象。每当一个类的对象被创建时,构造函数会自动被调用,以确保对象在使用之前被正确地初始化。不要别构造二字所误导,构造函数不是为对象开辟空间,而是给对象进行初始化。

构造函数的基本特点:

  1. 名称:构造函数的名字与类名相同。
  2. 没有返回类型:构造函数没有返回类型,也不需要写 return 语句。
  3. 自动调用:构造函数在对象创建时自动被调用。
  4. **重载:**构造函数可以进行重载
  5. **默认生成:**若用户没有显示定义构造函数,那么编译器会自动生成一个无参的默认构造函数。

以上特点的综合案列:

前三点的代码示例:

#include <iostream>
using namespace std;
//构造函数的相关知识点
class Date
{
public:
	//构造函数名字与类名相同
	//无返回类型
	Date(int year = 1, int month = 1, int day = 1)
	{
		_year = year;
		_month = month;
		_day = day;
	}

	int _year;
	int _month;
	int _day;
};

int main()
{
    Date d1;//实列化对象后会自动调用对象
    //因为实列d1对象是没有给实参,所以会用缺省参数进行赋值
    cout<<d1._year<<"-"<<d1._month<<"-"<<d1._day<<endl;
    Date d2(2024,9,14);//构造时代入实参,会使用实参进行初始化
    cout<<d2._year<<"-"<<d2._month<<"-"<<d2._day<<endl;
    
    return 0;
}

输出:

1-1-1
2024-9-14

第四点案列:

#include <iostream>
using namespace std;
class Example
{
public:

	Example(int a, int b)
	{
		cout << "Example(int a,int b)" << endl;
	}

	Example(double a, double b)
	{
		cout << "Example(double a, double b)" << endl;
	}
};

int main()
{
	Example e1(1, 2);
	Example e2(1.0, 2.0);

	return 0;
}

输出:

Example(int a,int b)
Example(double a, double b)

第五点案列:

#include <iostream>
using namespace std;

class Date
{
public:
	int _year;
	int _month;
	int _day;
};

int main()
{
	Date d1;

	return 0;
}

注:

在部分编译器下,上面的代码不会报错,但在较高的版本的编译器下,会检测到未初始化的错误,使用编译器默认生成的构造函数,成员变量将变成随机值

  1. **默认构造函数:**无参构造函数、全缺省构造函数、我们不写构造函数时编译器自动生成的构造函数,都是默认构造函数。上面三种默认构造函数只能有一个存在,不能同时存在

案例:

#include <iostream>
using namespace std;

class Date
{
public:
	Date(int year = 1, int month = 1, int day = 1)
	{
		_year = year;
		_month = month;
		_day = day;
	}

	Date()
	{
		_year = 2024;
		_month = 9;
		_day = 14;
	}
private:
	int _year;
	int _month;
	int _day;
};

int main()
{
	Date d1;

	return 0;
}
  1. **自定义类型成员变量:**编译器自动生成的默认构造函数,对内置类型(如:int,double)的成员变量的初始化不做要求,但对自定义类型(也就是类类型)会调用它的构造函数

案列:

#include <iostream>
using namespace std;

class Myclass
{
public:
	Myclass(int x = 10)
	{
		_x = x;
		cout << "内置类型的构造函数" << endl;
	}
private:
	int _x;
};

class Example
{
private:
	int n;
	Myclass n1;
};

int main()
{
	Example n1;

	return 0;
}

输出:

内置类型的构造函数

3.析构函数

在C++中,析构函数(Destructor)是一种特殊的成员函数,当对象的生命周期结束时,它被自动调用,用于清理对象的资源,释放内存,关闭文件等。析构函数的设计对于管理动态内存或其他系统资源的对象尤为重要。

3.1. 析构函数的定义

析构函数的名称与类名相同,但在前面加上一个波浪号 (~),它没有返回值,也不能接受参数,也就是说析构函数不能被重载。

基本定义格式:

class MyClass {
public:
    ~MyClass() {
        // 清理资源的代码
    }
};

3.2. 析构函数的特点

  • 函数名:析构函数名是在类名前加上字符~
  • 自动调用:当对象生命周期结束时,析构函数会自动调用。

示例:

#include <iostream>
using namespace std;

class Myclass
{
public:
	~Myclass()
	{
		cout << "调用Myclass析构函数" << endl;
	}

private:
	int a;
};

class Myclass1
{
public:
	~Myclass1()
	{
		cout << "调用Myclass1析构函数" << endl;
	}

private:
	int a;
};

void test()
{
	Myclass1 s2;
	//s2的析构函数先调用
	//因为s2的生命周期随这函数结束而结束
}

int main()
{
	Myclass s1;
	//s1的析构函数后调用
	//因为s1要等程序结束后生命周期才会结束
	test();

	return 0;
}

输出:

调用Myclass1析构函数
调用Myclass析构函数

  • 无参数、无返回值:析构函数不能有参数,也没有返回值,因此不能被重载。
  • **自定义类型成员:**我们不写析构函数,而使用编译器自动生成的析构函数时,该析构函数对内置类型的成员不做处理,对自定义类型成员会调用他们的析构函数。

事例:

#include <iostream>
using namespace std;

class Myclass1
{
public:
	~Myclass1()
	{
		cout << "调用Myclass1析构函数" << endl;
	}

private:
	int a;
};

class Myclass
{
public:

private:
	int a;
	Myclass1 s1;
};


int main()
{
	Myclass s1;

	return 0;
}

输出:

调用Myclass1析构函数

  • 即使显示写了析构函数,对于自定义类型成员依然会调用他的析构函数
  • **析构顺序:**一个局部有多个对象,C++规定后定义的先析构

4.拷贝构造函数

拷贝构造函数在C++中是一种特殊的构造函数,用于通过另一个同类型对象来初始化新对象。它在对象的值需要被复制时非常有用,特别是在对象中包含动态分配的资源时。

4.1. 拷贝构造函数的定义

拷贝构造函数的定义形式是接受自身类类型的一个 const 引用参数。这样可以避免构造新对象时产生无限递归调用

定义格式:

class MyClass {
public:
    MyClass(const MyClass& other);  // 拷贝构造函数声明
};

拷贝构造特点:

1.拷贝构造函数的调用时机

拷贝构造函数在以下几种情况下会被调用:

  • 对象以值传递的方式作为函数参数:当对象通过值传递给函数时,会调用拷贝构造函数。
  • 对象作为函数的返回值:当函数返回一个对象(按值返回),会调用拷贝构造函数。
  • 显式复制对象:当创建一个对象并显式将另一个对象赋给它时,会调用拷贝构造函数。
  • 使用对象初始化另一个对象:例如在对象声明时使用等号进行赋值时,拷贝构造函数会被调用。

2.浅拷贝与深拷贝

  • 浅拷贝(Shallow Copy)是编译器生成的默认行为,逐个拷贝对象中的每个成员变量。这对于值类型的成员变量是可行的,但如果对象持有指针或动态分配的内存,浅拷贝就可能引发问题。

示列:

#include <iostream>
using namespace std;

class MyClass {
public:

    MyClass(int val) {
        ptr = new int(val);  // 动态分配内存
    }

    ~MyClass() {
        delete ptr;  // 释放内存
    }

    // 默认的拷贝构造函数执行浅拷贝
    //默认的拷贝构造函数不写编译器会自动生成

private:
    int* ptr;
};

int main() {
    MyClass obj1(10);
    MyClass obj2 = obj1;  // 调用默认拷贝构造函数,执行浅拷贝

    // 此时 obj1.ptr 和 obj2.ptr 指向同一块内存
    return 0;
}

在这里插入图片描述

在上例中,obj1obj2 中的指针 ptr 指向同一块内存。如果析构时两个对象分别调用 delete ptr,会导致 重复释放(double free) 错误。

  • 深拷贝(Deep Copy)则需要在拷贝构造函数中手动编写代码,以正确地复制指向的内存等资源,确保每个对象拥有自己的独立资源。

示例:

#include <iostream>
using namespace std;

class MyClass {
public:
    MyClass(int val) {
        ptr = new int(val);  // 动态分配内存
    }

    ~MyClass() {
        delete ptr;  // 释放内存
    }

    // 深拷贝:分配新内存并复制内容
    MyClass(const MyClass& other) {
        ptr = new int(*other.ptr);  // 深拷贝
        std::cout << "调用深拷贝" << std::endl;
    }

    int* GetMem()
    {
        return ptr;
    }
private:
    int* ptr;
};

int main() {
    MyClass obj1(10);
    MyClass obj2 = obj1;  // 调用深拷贝构造函数

    std::cout << "obj1.ptr points to " << obj1.GetMem() << std::endl;
    std::cout << "obj2.ptr points to " << obj2.GetMem() << std::endl;

    return 0;
}

在深拷贝中,obj1obj2ptr 指针分别指向不同的内存地址,从而避免了重复释放内存的错误。

5.赋值运算符重载

5.1运算符重载

什么是运算符重载?

运算符重载(Operator Overloading)是C++中的一种功能,它允许开发者为用户定义的类型(如类和结构体)重新定义或“重载”现有的运算符,使其适用于这些类型。运算符重载可以使代码更直观、更易读,从而提高代码的可维护性。

运算符重载的基本原则

  1. 不能创建新的运算符:只能重载已有的运算符。
  2. 必须保留运算符的优先级和结合性:重载运算符时不能改变其固有的优先级和结合性。
  3. 至少有一个操作数是用户定义类型:防止对内置类型的运算符进行无意义的重载。

运算符重载的语法

运算符重载可以通过类的成员函数或友元函数来实现。基本语法如下:

成员函数

ReturnType operatorOp(const ClassName& other);

友元函数

friend ReturnType operatorOp(const ClassName& lhs, const ClassName& rhs);

示例:重载常见运算符

重载算术运算符(如+

class Complex {
private:
    double real;
    double imag;
public:
    Complex(double r = 0, double i = 0) : real(r), imag(i) {}

    // 重载+运算符,作为成员函数
    Complex operator+(const Complex& other) const {
        return Complex(real + other.real, imag + other.imag);
    }

    void print() const {
        std::cout << real << " + " << imag << "i" << std::endl;
    }
};

int main() {
    Complex c1(3.0, 4.0);
    Complex c2(1.0, 2.0);
    Complex c3 = c1 + c2; // 使用重载的+运算符
    c3.print(); // 输出:4 + 6i
    return 0;
}

重载关系运算符(如==

class Complex {
private:
    double real;
    double imag;
public:
    Complex(double r = 0, double i = 0) : real(r), imag(i) {}

    // 重载==运算符,作为成员函数
    bool operator==(const Complex& other) const {
        return (real == other.real) && (imag == other.imag);
    }
};

int main() {
    Complex c1(3.0, 4.0);
    Complex c2(3.0, 4.0);
    if (c1 == c2) { // 使用重载的==运算符
        std::cout << "c1 and c2 are equal" << std::endl;
    }
    return 0;
}

重载流插入和流提取运算符(<<>>

这些运算符通常重载为友元函数。

class Complex {
private:
    double real;
    double imag;
public:
    Complex(double r = 0, double i = 0) : real(r), imag(i) {}

    // 友元函数重载<<运算符
    friend std::ostream& operator<<(std::ostream& os, const Complex& c) {
        os << c.real << " + " << c.imag << "i";
        return os;
    }

    // 友元函数重载>>运算符
    friend std::istream& operator>>(std::istream& is, Complex& c) {
        is >> c.real >> c.imag;
        return is;
    }
};

int main() {
    Complex c;
    std::cout << "Enter a complex number (real and imaginary parts): ";
    std::cin >> c; // 使用重载的>>运算符
    std::cout << "You entered: " << c << std::endl; // 使用重载的<<运算符
    return 0;
}

5.2赋值运算符重载

重载赋值运算符(=

重载赋值运算符时,通常需要考虑自赋值、资源管理等问题。

class MyClass {
private:
    int* data;
public:
    MyClass(int val) {
        data = new int(val);
    }

    ~MyClass() {
        delete data;
    }

    // 重载=运算符,作为成员函数
    MyClass& operator=(const MyClass& other) {
        if (this == &other) {
            return *this; // 处理自赋值
        }
        delete data; // 释放旧内存
        data = new int(*other.data); // 分配新内存并复制值
        return *this;
    }
};

5.3日期类的实现

//Date.cpp文件中
#include "Date.h"

Date::Date(int year, int month, int day)
{
	_year = year;
	_month = month;
	_day = day;
}


int Date::GetMonthDay(int year, int month)
{
	static int arr[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };

	if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
	{
		return 29;
	}
	else
	{
		return arr[month];
	}

}

Date::Date(const Date& d)
{
	_year = d._year;
	_month = d._month;
	_day = d._day;
}

Date& Date::operator=(const Date& d)
{
	_year = d._year;
	_month = d._month;
	_day = d._day;

	return *this;
}

void Date::Print()
{
	cout << _year << "-" << _month << "-" << _day << endl;
}
bool Date::operator==(const Date& d)
{
	if (_year == d._year && _month == d._month && _day == d._day)
	{
		return true;
	}

	return false;
}
bool Date::operator>(const Date& d)
{
	if (_year > d._year)
	{
		return true;
	}
	else if (_year == d._year && _month > d._month)
	{
		return true;
	}
	else if (_year == d._year && _month == d._month && _day > d._day)
	{
		return true;
	}

	return false;
}
bool Date::operator>=(const Date& d)
{
	return *this > d || *this == d;
}
bool Date::operator<(const Date& d)
{
	return !(*this >= d);
}
bool Date::operator<=(const Date& d)
{
	return !(*this > d);
}

bool Date::operator!=(const Date& d)
{
	return !(*this == d);
}


Date& Date::operator+=(int day)
{
	if (day < 0)
	{
		*this -= -day;
	}
	else
	{
		_day += day;
		while (_day > GetMonthDay(_year, _month))
		{
			_day -= GetMonthDay(_year, _month);
			_month++;
			if (_month == 13)
			{
				_year++;
				_month = 1;
			}
		}
	}

	return *this;
}

Date Date::operator+(int day)
{
	Date temp(*this);

	temp += day;

	return temp;
}


//日期-=天数
Date& Date::operator-=(int day)
{
	if (day < 0)
	{
		*this += -day;
	}
	else
	{
		_day -= day;
		while (_day < 0)
		{
			_month--;
			if (_month == 0)
			{
				_year--;
				_month = 12;
			}
			_day += GetMonthDay(_year, _month);
		}
	}

	return *this;
}


//日期-天数
Date Date::operator-(int day)
{
	Date temp(*this);

	temp -= day;

	return temp;
}


//前置++
Date& Date::operator++()
{
	*this += 1;
	return *this;
}
//后置++
Date Date::operator++(int)
{
	Date temp(*this);
	*this += 1;
	return temp;
}

//前置--
Date& Date::operator--()
{
	*this -= 1;
	return *this;
}
//后置--
Date Date::operator--(int)
{
	Date temp(*this);
	*this -= 1;
	return temp;
}

//日期-日期返回天数
int Date::operator-(const Date& d)
{
	int count = 0;
	int flag = 1;
	Date max(*this);
	Date min(d);

	if (max < min)
	{
		max = d;
		min = *this;
		flag = -1;
	}
	while (min!=max)
	{
		count++;
		min++;
	}

	return flag*count;
}

ostream& operator<<(ostream& out, const Date& d)
{
	out << d._year << "-" << d._month << "-" << d._day ;

	return out;
}

istream& operator>>(istream& in, Date& d)
{
	in >> d._year >> d._month >> d._day;
	return in;
}
//Date.h
#include <iostream>
using namespace std;

class Date
{
	friend ostream& operator<<(ostream& out, const Date& d);
	friend istream& operator>>(istream& in, Date& d);
public:
	//打印日期
	void Print();
	//获取某年某月的天数
	int GetMonthDay(int year, int month);
	//全缺省的构造函数
	Date(int year = 1, int month = 1, int day = 1);

	//拷贝构造函数
	Date(const Date& d);

	//赋值运算符重载
	Date& operator=(const Date& d);

	bool operator==(const Date& d);
	bool operator>(const Date& d);
	bool operator>=(const Date& d);
	bool operator<(const Date& d);
	bool operator<=(const Date& d);
	bool operator!=(const Date& d);

	//日期+=天数
	Date& operator+=(int day);
	//日期+天数
	Date operator+(int day);
	//日期-=天数
	Date& operator-=(int day);
	//日期-天数
	Date operator-(int day);

	//前置++
	Date& operator++();
	//后置++
	Date operator++(int);

	//前置--
	Date& operator--();
	//后置--
	Date operator--(int);


	//日期-日期返回天数
	int operator-(const Date& d);

private:
	int _year;
	int _month;
	int _day;
};

🥇结语

C++中的默认成员函数为我们简化了许多常见的类操作,尤其是在类的基本功能设计上提供了便捷性。然而,在涉及资源管理、动态内存分配等复杂场景时,我们必须清楚了解编译器生成的默认行为,避免潜在的问题。通过深入掌握默认成员函数的工作机制,程序员可以更灵活地控制对象的构造、赋值和销毁,编写出更加健壮的C++程序。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2169543.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

smtp-server: 535 Error: authentication faile

问题描述&#xff1a; 在linux服务器上使用 mailx发送邮件时提示&#xff1a;smtp-server: 535 Error: authentication faile 原因&#xff1a;没有配置授权码或者授权码不正确 解决办法&#xff1a;配置授权码(以网易邮箱为例) 1. 进入网易邮箱网页版&#xff0c;打开 POP…

数据中心里全速运行的处理器正在浪费能源

数据中心是耗电大户&#xff0c;运营商一直在努力解决的一个关键问题是如何减少能源和资源消耗。人们已经找到了一些巧妙的解决方案&#xff0c;例如使用非饮用水来冷却设备&#xff0c;但一个显而易见的解决方案似乎被忽略了&#xff1a;启用处理器的各种省电功能。 随着需求的…

进程概念以及进程相关函数的使用

1.进程相关概念 1.1 程序和进程 程序&#xff0c;是指编译好的二进制文件&#xff0c;在磁盘上&#xff0c;不占用系统资源(cpu、内存、打开的文件、设备、锁....) 进程&#xff0c;是一个抽象的概念&#xff0c;与操作系统原理联系紧密。进程是活跃的程序&#xff0c;占用系…

Qt-QGroupBox容器类控件(39)

目录 容器类控件 描述 属性 使用 容器类控件 描述 这个是用来分组的&#xff0c;即把控件分组 使⽤ QGroupBox 实现⼀个带有标题的分组框.可以把其他的控件放到⾥⾯作为⼀组.这样看起来能更好看⼀点 属性 title分组框的标题alignment分组框内部内容的对⻬⽅式flat是否是…

微服务nacos解析部署使用全流程

1、什么是Spring Cloud Spring Cloud是一系列框架的集合。它利用Spring Boot的开发便利性巧妙地简化了分布式系统基础设施的开发&#xff0c;如服务发现注册、配置中心、消息总线、负载均衡、断路器、数据监控等&#xff0c;都可以用Spring Boot的开发风格做到一键启动和部署。…

stm32入门——GPIO输入输出(1)基础理解

最近比较想上进&#xff0c;又不知道要干什么&#xff0c;就来水几篇博客欺骗一下自己。 GPIO全称是&#xff1a;General Purpose Input / Output ,是stm32用于控制输入和输出信号的通用接口。我们用的MCU都有这玩意&#xff0c;比如STM32F103C8T6上有 GPIOA&#xff0c;GPIOB&…

算法葫芦书(笔试面试)

一、特征工程 1.特征归一化&#xff1a;所有特征统一到一个区间内 线性函数归一化&#xff08;0到1区间&#xff09;、零均值归一化&#xff08;均值0&#xff0c;标准差1&#xff09; 2.类比型特征->数值性特征 序号编码、独热编码、二进制编码&#xff08;010&#xf…

prd文档编写(to b)

如何编写产品需求文档&#xff08;PRD&#xff09; | 人人都是产品经理 (woshipm.com) 一.prd文档编写得目的 PRD文档最为重要的目的就是&#xff1a;协调各个相关角色 PRD就是提高效率的&#xff0c;把各个角色的共识全部写出来&#xff0c;大家都已PRD为最终的工作指导文档…

2:数据结构:列表与元组

目录 2.1 列表的创建与操作 2.1.1 列表的创建 2.1.2 列表的常用操作 2.1.3 列表切片操作 2.2 元组的特点与用法 2.2.1 元组的创建 2.2.2 元组与列表的区别 2.2.3 元组的常用操作 2.3 示例代码与练习 2.3.1 示例代码&#xff1a;列表与元组的基本操作 2.3.2 练习题 文…

ICM20948 DMP代码详解(46)

接前一篇文章&#xff1a;ICM20948 DMP代码详解&#xff08;45&#xff09; 上一回讲到了inv_icm20948_setup_compass_akm函数中的以下代码片段&#xff1a; /* Set compass in power down through I2C SLV for compass */result inv_icm20948_execute_write_secondary(s, COM…

网口为什么叫RJ45接口,名字的由来?

大家有没有注意到很多地方“网口”都被称作“RJ45”接口。但是&#xff0c;您是否曾经好奇过&#xff0c;这个小小的插孔为何被称为“RJ-45”&#xff1f;这个名字背后又有着怎样的故事呢&#xff1f; RJ-45的全称与定义 首先&#xff0c;我们需要了解“RJ-45”的全称是“Regi…

jetlinks物联网平台学习3:mqtt协议及物模型

mqtt协议及物模型 1、创建产品2、配备设备接入方式3、上传消息协议4、填写网关信息5、配置mqtt认证信息6、配置物模型7、创建设备8、使用MQTT X模拟设备接入9、mqttx实现设备->平台 平台->设备 消息发送9.1、属性上报9.2、获取最新属性值&#xff08;读取属性&#xff09…

EEPROM手册笔记

目录 一、特征描述二、功能描述三、总线特性四、设备寻址五、写入操作1.字节写入2.页写入 六、读取操作1.当前地址读取2.随机读取3.顺序读取 一、特征描述 1.Microchip Technology Inc. 24AA04/24LC04B &#xff08;24XX04*&#xff09; 是一款 4 Kbit 电气可擦除 PROM。该器件…

ChatDev:基于对话的多智能体协同软件开发框架

相关代码资源见文末 论文地址:ChatDev: Communicative Agents for Software Development - ACL Anthologyhttps://aclanthology.org/2024.acl-long.810/ 1. 概述 1.1. 当前的挑战 软件开发是一个复杂且多层次的过程,要求具备不同技能的团队成员之间密切合作。例如,架构师…

老人跌倒扶不扶?涪城三职工给出响亮答案

一、关键时刻的选择 于绵阳市三江湖湿地公园&#xff0c;平凡午后&#xff0c;三名环卫人员刘后刚、严荣礼及杨树坤正紧张作业。突闻呼救声&#xff0c;一位老人在石阶上跌倒需援手。在紧急关头&#xff0c;他们果断抛却工具&#xff0c;疾速赶至老人身边。此举不仅展现了他们…

了解网络的相关信息

文章目录 前言了解网络的相关信息1. ip是什么?1.1. 公网IP:1.2. 私有IP:1.2.1. 示例 2. 子网掩码3. 子网掩码的划分网段是什么4. 特殊的回路IP网段(127.0.0.1)5. 端口 前言 如果您觉得有用的话&#xff0c;记得给博主点个赞&#xff0c;评论&#xff0c;收藏一键三连啊&#x…

学习C++的第七天!

1.虚函数是在基类中用 virtual 关键字声明的函数&#xff0c;可以在派生类中被重写。纯虚函数是在虚函数的基础上&#xff0c;在基类中被初始化为 0 的函数&#xff0c;含有纯虚函数的类是抽象类&#xff0c;不能被实例化。 2.如果基类的析构函数不是虚函数&#xff0c;当通过…

(done TODO:从频谱到时域要考虑负频波和余弦波?) 傅里叶变换知识补充

参考&#xff1a;https://www.bilibili.com/video/BV1rC4y1E7FD/?vd_source7a1a0bc74158c6993c7355c5490fc600 sinx 和 sin2x sin3x 等整数倍频率的正弦波都是正交的 cosx 和 cos2x cos3x 等整数倍频率的余弦波都是正交的 这成为三角函数系的正交性 up主从分解出来的波恢复成…

buuctf [ACTF2020 新生赛]Include

学习笔记。 开启靶机。 进入靶场&#xff1a; 我们跟进 tips瞅瞅&#xff1a; 额&#xff0c;纯小白&#xff0c;能想到的就是先F12看看&#xff0c;在CTRLu、以及抓包。 得&#xff0c;不会了&#xff0c;看wp呗&#xff0c;不会死磕没脑子0,0&#xff1f; 参考&#xff1a;…

解决 Adobe 盗版弹窗

在这个文件夹下删除 Adobe CCXProcess 然后重装。 Adobe Premiere Pro 2024 (v24.6.1) Multilingual :: Варез от m0nkrusa [Warez by m0nkrus] (monkrus.ws) Adobe Photoshop 2024 (v25.12) Multilingual :: Варез от m0nkrusa [Warez by m0nkrus] (monkrus.…