Note that there are some explanatory texts on larger screens.

plurals
  1. POHeader file and namespace confusion
    primarykey
    data
    text
    <p>I'm trying to send an Album object from main to a function in another .cpp file but I'm getting errors when compiling: </p> <p>From main I create an Album object and then try to pass it to the menu function like so:</p> <pre><code>Model::Album album("TestAlbum"); View::Menu m; m.startMenu(album); </code></pre> <p>My menu class:</p> <pre><code>#include "stdio.h" #include "Menu.hpp" #include "AlbumOps.hpp" #include "Album.hpp" #include &lt;iostream&gt; using namespace std; namespace View { void Menu::startMenu(Model::Album inAlbum) //compile errors happen here { int option = 1; while (option!=5) { cout &lt;&lt; "1. Add image to album\n"; cout &lt;&lt; "2. Remove image from album\n"; cout &lt;&lt; "3. List all images in album\n"; cout &lt;&lt; "4. View image in album\n"; cout &lt;&lt; "5. Quit\n"; //and so on </code></pre> <p>When I try to compile this, I get errors on the void Menu::startMenu(Model::Album inAlbum) line</p> <p>'Model' has not been declared</p> <p>Model is a namespace I use. I thought including the Album.hpp would fix this but it hasn't and I'm at a loss for how to fix this.</p> <p>Edit: Menu is a class, here is my Menu.hpp:</p> <pre><code>#ifndef MENU_H //"Header guard" #define MENU_H namespace View { class Menu { public: void startMenu(Model::Album inAlbum); }; } #endif </code></pre> <p>And my Album.hpp:</p> <pre><code>#ifndef ALBUM_H #define ALBUM_H #include &lt;string&gt; #include &lt;vector&gt; #include "Image.hpp" namespace Model{ class Album { private: std::vector&lt;Image*&gt; 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 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload