c++ - C++ Visual Studio Error: name followed by '::' must be a class or namespace name (DirectX 11)
问题描述
I dont understand what's wrong here
manager.h
#pragma once
class CManager
{
public:
static void Init();
static void Uninit();
static void Update();
static void Draw();
};
main.cpp
#include "main.h"
#include "manager.h"
...
CManager::Init(); //error here
...
CManager::Update(); //error here
CManager::Draw(); //and here
But name followed by :: is already a class. Why does it show me an error?
解决方案
看起来你想调用你的函数,不是吗?如果我是对的,那么您需要先定义您的函数,然后才能调用它们。
class CManager
{
public:
static void Init();
static void Uninit();
static void Update();
static void Draw();
};
在这里,您只声明了它们。
您必须在类中定义它们:
class CManager
{
public:
static void Init()
{
//Do something...
}
static void Uninit()
{
//...
}
static void Update()
{
//...
}
static void Draw()
{
//...
}
};
...或在你的课外:
void CManager::Init()
{
//Do something...
}
//and so on...
推荐阅读
- java - Why my GridView cuts off at The End?
- vba - 强制重新计算的按钮(Application.Volatile?)
- java - 从不受弹簧数据休息管理的控制器返回实体对象
- r - 将 R 与 MySQL 连接
- git - Git 使用什么数据库存储元数据以及如何访问它?
- ios - 如何在 ScrollView Swift 中为图像更改设置动画
- javascript - 点击功能在jquery中不起作用
- javascript - React 的 componentDidMount() 中的三元运算符问题
- php - 通过 mqseries 库 php 对 MQ 进行身份验证
- ios - 未找到签名证书“iOS 开发”