2017-07-10 9 views
1

私は迷っているので、誰かが助けてくれることを願っています。プリコンパイル済みヘッダーを探しながら、ファイルの予期しない終わり:以前の私のプログラムを実行している場合、それは今、いくつかの理由で、私は、エラーメッセージにプリコンパイル済みヘッダーの問題?

致命的なエラーC1010を取得し、うまく働きました。ソースに '#include "stdafx.h"'を追加することを忘れましたか?

これにはヘッダーが含まれています。目標は、時間と日付を印刷し、2つの異なるファイルを持つウィンドウとフォントと背景色のサイズを入力できるプログラムを作成することでした。最初のファイルは次のとおりです。

#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. 
} 

以下は私の2番目のファイルです。

// 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; 
} 

ご迷惑をおかけして申し訳ございません。

+0

両方のソースファイルに 'stdafx.h'を含めましたか?最初のケースではそうではないようです。 – iehrlich

+0

私はそれを試みました、同じ問題 –

答えて

0

"TimeClass.h"を確認しましたか?私は.hファイルに由来する同様のエラーを見た。

私はこのコメントにする必要があります知っているが、そのための十分な評判を持っていない:(

+0

私は、残念ながら私は何も見ていないです。奇妙な部分は、それが以前に実行されていたことです、私はプログラムを閉じて、それを開き、今これが起こっている。 –

+0

#if/#ifdefと一致する#endifがあるかどうか確認してください。何度も私たちはそのペアを見逃しています – Harsh

+0

@CollinLynch、[msdn](https://msdn.microsoft.com/en-us/library/d7fz9ckx(v = versus90).aspx)をチェックしましたか? – Harsh

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" 
関連する問題