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

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

所以我正在做一个uni项目,当我尝试编译一个奇怪的错误时 pop 。

#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

我添加了 friend ,因为我在另一个类中有一个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

最佳答案

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

如果您无法找出错误,请请求预处理器输出并阅读以了解问题。/SHOWINCLUDES也可能有帮助。

关于c++ - 不存在的行上的C++编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17391171/

相关文章:

c - 为什么 Visual Studio 2010/12 在 Debug模式下运行程序会占用大量内存和时间?

asp.net - appharbor 在推送后编译时出错

c++ - 带有指针构造函数的指针

c++ - 从另一个进程获取加载的模块

c++ - 设置 Complex Double 的 Max 值以替换 Infinity

c++ - 如何用头文件确定函数定义?

c++ - 如果参数采用引用,在函数参数中传递 *this 会导致内存泄漏吗?

C# MySQL 无法识别输入

c# - LINQ to Entities 无法识别方法 'System.String ToString()' 方法 MVC3

perl - 如何将Cygwin的perl版本从5.22降级到5.14?