# GameObject::AddComponent 添加元素或建立关联。 ```cpp template T* AddComponent(Args&&... args); ``` 该方法声明于 `XCEngine/Components/GameObject.h`,当前页面用于固定 `GameObject` 类目录下的方法级 canonical 路径。 **参数:** - `args` - 参数语义详见头文件声明。 **返回:** `template T*` - 返回值语义详见头文件声明。 **示例:** ```cpp #include void Example() { XCEngine::Components::GameObject object; // 根据上下文补齐参数后调用 GameObject::AddComponent(...)。 (void)object; } ``` ## 相关文档 - [返回类总览](GameObject.md) - [返回模块目录](../Components.md)