我在想我已經激怒了「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