当前位置: 首页 > news >正文

【虚幻C++笔记】接口

目录

  • 概述
  • 创建接口

概述

  • 简单的说,接口提供一组公共的方法,不同的对象中继承这些方法后可以有不同的具体实现。
  • 任何使用接口的类都必须实现这些接口。
  • 实现解耦
  • 解决多继承的问题

创建接口

在这里插入图片描述

// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "MyInterface.generated.h"// This class does not need to be modified.
UINTERFACE(MinimalAPI)
class UMyInterface : public UInterface
{GENERATED_BODY()
};/*** */
class GENERALFRAMEWORK_API IMyInterface
{GENERATED_BODY()// Add interface functions to this class. This is the class that will be inherited to implement this interface.
public:
// 纯虚函数,实现类必须实现接口virtual void MyInterface_PureVirtual() = 0;// 虚函数,在接口本身的 .h 或 .cpp 文件中提供默认实现.实现类可覆盖virtual void MyInterface_Virtual();//实现类可以在蓝图和C++中实现接口UFUNCTION(BlueprintCallable, BlueprintNativeEvent)void MyInterface_NativeEvent1(int32 number);//实现类在蓝图中实现接口UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)void MyInterface_ImplementableEvent();
};

相关文章:

  • MySQL联表查询底层原理
  • http/https请求解析
  • Pikachu靶场——Cross-Site Scripting
  • 需求分析---软件架构师武器库中的天眼系统
  • 记录小程序第一次调用Api,基于腾讯云Serverless函数,实现小程序的成功接入api,以及数据调用
  • 实验四 中断实验
  • 【Linux】第七章 控制对文件的访问
  • 实现类似 “更新中” 的水平进度条按钮效果
  • 高级java每日一道面试题-2025年4月10日-微服务篇[Nacos篇]-Nacos的服务健康检查机制是如何工作的?
  • 下载maven低版本(官网)
  • 网站301搬家后谷歌一直不收录新页面怎么办?
  • maven如何解决jar包依赖冲突
  • Maven 多仓库和多镜像配置
  • 红宝书第四十七讲:Node.js服务器框架解析:Express vs Koa 完全指南
  • 408 计算机网络 知识点记忆(9)
  • 【今日三题】添加字符(暴力枚举) / 数组变换(位运算) / 装箱问题(01背包)
  • 阿里云短信服务与ASP.NET对接实例
  • 21、c#中“?”的用途
  • TDengine 语言连接器(R语言)
  • 【QT】常用控件 【多元素类 | 容器类 | 布局类】
  • 做门户网站有前途吗/四川企业seo推广
  • 惠州网页模板建站/买卖网交易平台
  • 企业做网站用dedeCMS免费吗/google官网登录
  • 网站建设的展望 视频/免费网站做seo
  • 惠州哪个房地产网站做的比较好/谷歌商店官网
  • 男女做暧暧试看网站/站长seo推广