月度归档: 2024 年 10 月

10 篇文章

Coordinate System
Coordinate System The coordinate system is controlled by the QPainter class. Together with the QPaintDevice and QPaintEngine classes, QPainter form the basis of Qt's painting …
Qt Widgets Designer Form Class文件的解读
示例 chatwindows.h #ifndef CHATWINDOW_H #define CHATWINDOW_H #include <QWidget> // 前置声明,Ui::ChatWindow是通过designer自动生成的,因此需要先声明 namespace Ui { class ChatWindow; } class Cha…
TCP/IP协议详解
Ethernet II 帧格式 目的MAC地址  占用6字节 源MAC地址  占用6字节 帧类型  占用2字节 数据payload  占用46字节~1500字节 源MAC地址  占用4字节 Ethernet II 帧的最小和最大长度 最小帧长度:64 字节(包括帧头和 FCS)。如果有效载荷部分小于…
TCP网络编程
第八章 IP地址和域名之间的转换 利用域名获取IP地址 #include <netdb.h> struct hostent * gethostbyname(const char * hostname); hostent结构体定义如下: struct hostent { char * h_name; char ** h_aliases; …
C++ 模板编程
第一章 函数模板 函数模板初探 定义模板 定义一个返回最大值的函数模板 template<typename T> T max(T a, T b) { return b < a ? a : b; } 这里T表示类型参数,是模板参数。 使用模板 #include "max1.hpp" #include <io…
创建型设计模式
抽象工厂(Abstract Factory) 适用性 一个系统要独立于它的产品的创建、组合和表示时。 一个系统要由多个产品系列中的一个来配置时。 当你要强调一系列相关的产品对象的设计以便进行联合使用时。 当你提供一个产品类库,而只想显示它们的接口而不是实现时。
UML 类图
类图的几种关系 Association 关联 Dependency 依赖 Aggregation 聚合 Composition 组合 Inheritance 继承 Implementation 实现 关联 单向关联 class Teacher { public: Teacher(const std::string& name) : name…
C++ 异常处理
class myexception: public exception { virtual const char* what() const throw() { return "My exception happened"; } }; int main () { try { throw myexception(); } catc…
C++ 类
类的形式 class Rectangle { int width, height; public: void set_values (int x,int y); int area() {return width*height;} }; 构造函数 class Rectangle { public: Rectangle() { cout <<…