预编译标头有问题?
Issues with precompiled headers?
希望有人能帮忙,因为我迷路了。 早些时候运行我的程序时,它工作正常,现在由于某种原因我收到错误消息
致命错误 C1010:查找预编译标头时文件意外结束。您是否忘记将"#include"stdafx.h"添加到您的源中?
我确实包括标题。目标是创建一个程序,该程序可以打印时间和日期,并能够输入窗口的大小以及具有两个不同文件的字体和背景颜色。第一个文件如下所示。
#include "TimeClass.h"
////////////////////////////////////////////////////////////////////////////
// Class to help with the usage of time.
//////////////////////////////////////////////////////////////////////////
CTimeClass::CTimeClass()
{
// Notice that the time is stored whenever this time object is created.
// Use this to your advantage in "main".
// "m_st" holds the time and date information.
GetLocalTime(&m_st);
}
////////////////////////////////////////////////////////////////////////
CTimeClass::~CTimeClass()
{
// Empty - Nothing to destroy here.
}
short CTimeClass::Year()
{
// Place your code here to return the year as a short.
ConsoleTime ct;
short year = ct.wYear;
return year;
}
///////////////////////////////////////////////////////////////////////////
string CTimeClass::Month()
{
ConsoleTime ct;
int month = cm.wMonth;
if (month == 0)
return "January";
else if (month == 1)
return "February";
else if (month == 2)
return "March";
else if (month == 3)
return "April";
else if (month == 4)
return "May";
else if (month == 5)
return "June";
else if (month == 6)
return "July";
else if (month == 7)
return "August";
else if (month == 8)
return "September";
else if (month == 9)
return "October";
else if (month == 10)
return "November";
else if (month == 11)
return "December";
else
return "error";
// Place your code here to return the month as a string.
}
//////////////////////////////////////////////////////////////
short CTimeClass::Day()
{
ConsoleTime ct;
short day = ct.wDay;
return day;
// Place your code here to return the day as a short.
}
//////////////////////////////////////////////////////////////////////
string CTimeClass::DayOfWeek()
{
ConsoleTime ct;
int day == st.wDayOfWeek;
if (day == 0)
return "Sunday";
else if (day == 1)
return "Monday";
else if (day == 2)
return "Tuesday";
else if (day == 3)
return "Wednesday";
else if (day == 4)
return "Thursday";
else if (day == 5)
return "Friday";
else if (day == 6)
return "Saturday";
else
return "error";
// Place your code here to return the day of the week as a string.
}
//////////////////////////////////////////////////////////////////
short CTimeClass::Hour()
{
ConsoleTime ct;
short hour = ct.wHour;
return hour;
// Place your code here to return the hour as a short.
}
///////////////////////////////////////////////////////////////////////////
short CTimeClass::Minute()
{
ConsoleTime ct;
short minute = ct.wMinute;
return minute;
// Place your code here to return the minute as a short.
}
///////////////////////////////////////////////////////////////////////////
short CTimeClass::Second()
{
ConsoleTime ct;
short second = ct.wSecond;
return second;
// Place your code here to return the second as a short.
}
下面是我的第二个文件。
// ConsoleWindowClock.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
#include "ConsoleClass.h"
#include "TimeClass.h"
#include <iomanip>
#include <iostream>
#include <windows.h>
#include <stdlib.h>
using namespace std;
int main()
{
int width;
int height;
int fontsize;
int text;
int background;
int userclass;
int time;
userclass.ConsoleColor(text, background);
userclass.ConsoleWindowSize(width, height);
userclass.FontSize(fontsize);
cout << "This is the console window clock" << endl;
cout << "Please enter the window size in characters: " << endl;
cin >> width;
cin >> height;
cout << "Please enter the font size: " << endl;
cin >> fontsize;
cout << "Enter the Text color (0=Red, 1=Green, 2=Blue, -1=Random): " <<
endl;
cin >> text;
cout << "Enter the background color (0=Red, 1=Green, 2=Blue, -1=Random): "
<< endl;
cin >> background;
while (true)
{
cout << "The time is: " << time.Hour() << ":" << time.Minute() << ":" <<
time.Second() << endl;
cout << "The day of the week is: " << time.DayOfWeek() << endl;
cout << "The month, day, and year are: " << time.Month() << " " <<
time.Day() << ", " << time.Year() << endl;
Sleep(1000);
}
return 0;
}
任何帮助将不胜感激,对不起,长篇大论。
你搞砸了评论:
// ConsoleWindowClock.cpp : Defines the entry point for the console
application.
//
应该是
// ConsoleWindowClock.cpp : Defines the entry point for the console
// application.
此外,您应该在第一个文件中TimeClass.h
之前包含预编译标头。
#include "stdafx.h"
#include "TimeClass.h"
你看过你的"TimeClass.h"吗?我看到了源自.h文件的类似错误。
我知道这应该在评论中,但没有足够的声誉:(
相关文章:
- 我似乎对if/else的基本语句有问题:/
- 我在范围内未声明的错误类有问题
- 我的C++语言蛮力算法有问题
- 我关于函数"Assert"的C++代码有问题
- 标准对此指向成员函数类型模板参数有何说明?是我的代码有误,还是 MSVS 16.6 有问题?
- C++类中的友元函数有问题?
- libssh 问题编译问题未定义的错误
- 我对数组即 0x6dfe78 有问题
- 我对 std::unique(算法)C++有问题
- 使用 fstream 库并在屏幕上打印的文件有问题?
- 这个模板为什么有问题?如何正确编译
- 我对 MyGraph 属性顶点名称和边权重有问题
- delete[]有问题,如何部分删除内存
- 在C++中使用exit()退出程序有问题吗
- 预编译标头有问题?
- 对简单的帐户检查程序有问题?程序返回编译错误,指出"no match for 'operator||' unsure of how to fix?"
- gcc|从源代码编译有问题
- C++ PThreads 有问题,而不是编译
- 这个C++代码有什么问题?编译错误:调用“测试::测试(测试)”没有匹配函数
- 前缀计算器编译有问题