gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 11:05:17 24 4
gpt4 key购买 nike

所以我正在做一个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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com