«Не было объявлено в этой области» определение структуры ошибки.C ++ - PullRequest
0 голосов
/ 05 ноября 2011

Я думаю, что разозлил богов "Стражей Заголовка", но я не вижу где.Моя программа выглядит следующим образом: (примечание: это просто необходимая информация об этих файлах)

основной файл:

#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>

I get "Плейлист не был объявлен в этомобъем "на линии:

PlayList allSongs;

В моем основном файле.

Спасибо!

Ответы [ 3 ]

4 голосов
/ 05 ноября 2011

Проверьте вашу заглавную букву.

Playlist и PlayList используются.

2 голосов
/ 05 ноября 2011

Вы неправильно указали заглавную букву ... он объявлен как Playlist, используется как PlayList

1 голос
/ 05 ноября 2011

проверка орфографии clang полезна для такого рода вещей.

tmp.cpp:5:1: error: unknown type name 'PlayList'; did you mean 'Playlist'?
PlayList pl;
^~~~~~~~
Playlist
tmp.cpp:1:8: note: 'Playlist' declared here
struct Playlist {
       ^
1 error generated.
...