0

メインから別の .cpp ファイルの関数に Album オブジェクトを送信しようとしていますが、コンパイル時にエラーが発生します。

main から Album オブジェクトを作成し、次のようにメニュー関数に渡そうとします。

Model::Album album("TestAlbum");
View::Menu m;
m.startMenu(album);

私のメニュークラス:

#include "stdio.h"
#include "Menu.hpp"
#include "AlbumOps.hpp"
#include "Album.hpp"
#include <iostream>
using namespace std;

namespace View
{
void Menu::startMenu(Model::Album inAlbum) //compile errors happen here
    {
    int option = 1;
    while (option!=5)
        {
        cout << "1. Add image to album\n";
        cout << "2. Remove image from album\n";
        cout << "3. List all images in album\n";
        cout << "4. View image in album\n";
        cout << "5. Quit\n";
//and so on

これをコンパイルしようとすると、void Menu::startMenu(Model::Album inAlbum) 行でエラーが発生します。

「モデル」は宣言されていません

モデルは私が使用する名前空間です。Album.hpp を含めるとこれが修正されると思いましたが、修正されておらず、これを修正する方法がわかりません。

編集:メニューはクラスです。ここに私のMenu.hppがあります:

#ifndef MENU_H //"Header guard"
#define MENU_H

namespace View
{
class Menu
    {
    public:
    void startMenu(Model::Album inAlbum);
    };
}
#endif

そして私の Album.hpp:

#ifndef ALBUM_H
#define ALBUM_H

#include <string>
#include <vector>
#include "Image.hpp"

namespace Model{
class Album
{
  private:
    std::vector<Image*> imageList;
    std::string albumName;      


  public:
    Album(std::string);

    /****Setters****/
    void setAlbumName(std::string);
    void addImage(Image);

    /****Getters****/
    Image getImage(int);
    std::string getAlbumName();
    int getListLength();
};
}
#endif
4

1 に答える 1