C ++在不存在的行上编译错误

时间:2013-06-30 14:06:59

标签: c++ visual-studio-2012 compiler-errors

所以我正在做一个uni项目,当我尝试编译一个奇怪的错误弹出。我读过它可能是来自循环依赖,但我已经检查过,这不是问题,这里是标题代码:

#ifndef __ScheduleHeader_H_INCLUDED__
#define __ScheduleHeader_H_INCLUDED__

#include "TrainStationHeader.h"

class Schedule
{
friend class ScheduleIterator;
  public:
    //get data functions
    std::string getFromCity() { return fromCity; }
    std::string getToCity() { return toCity; }
    std::string getTrainID() { return trainID; }
    std::string getDate();
    std::string getTime();
    std::string getTimeForTickets();
    std::string getPrice() { return price; }    

    //set data functions + validation on the input data
    bool setFromCity();
    bool setToCity();
void setDate();
    void setTime();
    bool setTrainID();
    void setPrice();

    std::string createScheduleLine();

private:
    int validateDate(struct tm,struct tm);
    int validateTime(struct tm,struct tm);

    std::string scheduleFileName;
    std::string fromCity;
    std::string toCity;
    struct tm dateAndTime;
    std::string trainID;
    std::string price;
};

#endif

我添加了这位朋友,因为我在另一个类中有一个Schedule对象为private。编译时的错误是:

c:\program files (x86)\windows kits\8.0\include\um\schedule.h(60): error C2146: syntax         error : missing ';' before identifier 'Type'
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(60): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(61): error C2146: syntax error : missing ';' before identifier 'Offset'
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(61): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(68): error C2146: syntax error : missing ';' before identifier 'Size'
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(68): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(69): error C2146: syntax error : missing ';' before identifier 'Bandwidth'
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(69): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(70): error C2146: syntax error : missing ';' before identifier 'NumberOfSchedules'
1>c:\program files (x86)\windows kits\8.0\include\um\schedule.h(70): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

PS:我正在使用MC VS 2012

这里是TrainStation.h,它只是我在大多数课程中使用的一堆函数和库(我知道这不是最佳实践):

#ifndef __TrainStation_H_INCLUDED__
#define __TrainStation_H_INCLUDED__

#include <iostream>
#include <string>
#include <fstream>
#include <locale>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <vector>

std::string removeWhiteSpace(std::string a);

//Resieves the file on wich to operate upon and what to search for.
//If it finds it it returns the line on wich it has been found ,if not returns -1
int checkContent(std::string FileName, std::string target);

//Give the Function the File Name with wich you would like to work and the target that             you would like to delete
//It works by copying everything exept the target string to another file then renames it and deletes the old file
int deleteContent(std::string File,std::string target);

void renameFile(std::string , std::string);

bool checkFileState(std::ifstream &file);
#endif

1 个答案:

答案 0 :(得分:0)

错误消息表示“C:\ program files(x86)\ windows kits \ 8.0 \ include \ um \ schedule.h”中的错误,这是安装VS或其他SDK的一部分。您引用一个完全不同的头文件。

如果你无法弄清楚错误,请询问预处理器输出并阅读它以查看问题。 / SHOWINCLUDES也可以提供帮助。