我在想我已经激怒了“Header Guard”神,但我不知道在哪里。我的程序布局如下: (注意:这仅仅是对这些文件的相关信息)“未在此范围内声明”错误结构定义。 C++
主要文件:
#include "playlist.h"
#include "playlistitem.h"
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main (int argc, char** argv)
//snip
PlayList allSongs;
//snip
playist.h:
#ifndef PLAYLIST_H
#define PLAYLIST_H
#include <iostream>
#include <string>
#include <vector>
#include "playlistitem.h"
#include "song.h"
#include "time.h"
struct Playlist {
std::vector<Song> songs;
Time cdTotalTime;
int totalTime;
};
plalist.cpp :
#include <iostream>
#include <string>
#include <vector>
#include "playlist.h"
song.h:
#ifndef SONG_H
#define SONG_H
#include <iostream>
#include <string>
#include "time.h"
struct Song {
std::string title;
std::string artist;
std::string album;
int track;
Time length;
};
song.cpp:
#include "song.h"
#include "csv.h"
#include <sstream>
#include <vector>
我得到上线 “播放列表并没有在这个范围内声明”:
PlayList allSongs;
在我的主要文件。
谢谢!
在你的头文件末尾是否有#ifififif关闭了#ifndef'后卫? –
你为什么不发布实际的错误信息?当您的实际代码行使用“PlayList”时,您说错误消息指出“播放列表未在此范围内声明”。 – Marlon