我现在正在学习头文件和类,我似乎无法让它们工作。我看不出我做错了什么。我已将错误作为注释包含在编译器说有错误的地方。我该如何解决?
主文件
#include <iostream>
#include <conio.h>
#include "Header.h" //Error: In file included from C:\Users\Brandon\Desktop\
C++ Practice\Header Practice\Main.cpp
int main()
{
Header Test;
Test.Header(); Error: invalid use of `class Header'
getch();
return 0;
}
头文件.h
#ifndef Header_H_
#define Header_H_
class Header
{
public:
void Header(); //Error: return type specification for constructor invalid
};
#endif // Header_H_
和 Header.cpp。
#include "Header.h"
Header::Header()
{
std::cout << "Everything is working./n" << std::flush;
};