Hi im trying to get this to compile im try to make a menu this is my code but it wont work

//main.cpp

#include <iostream>
#include "Menu.h"
  
using namespace std;

int main(){
{
    SportsClothingMenu();
}
 
system("pause");
return 0;
}
//Menu.h

#ifndef H_MENU
#define H_MENU

#include <iostream>
#include <vector>
#include <string>

using namespaced std;


class SportsClothingMenu
{
private:
          Menu sportsClothingMenu;
          
public:
          SportsClothingMenu(){}
     
private:
          void _populate(){
               
                            Menu soccerClothesMenu("soccer");
                            //...add soccor clothes to soccerClothesMenu
                            sportsClothingMenu.add( soccerClothesMenu );
  }
};

#endif
//menulmp.cpp

#include "Menu.h"

using namespace std;

struct Menu
{
    std::string name; //could be menu name or a item name

    std::vector<Menu> subMenus;
    
    Menu(const std::string& name, const std::vector<Menu> subMenus): name(name), subMenus(subMenus){}
    
    void add(const Menu& m){ subMenus.push_back(m); 
    
   }
};

i cant seem to get it working :(

Your code has a lot of errors..

Menu soccerClothesMenu("soccer");

The Menu struct does not have a constructor that takes a string as a parameter. Rather, the only constructor int the struct:

Menu(const std::string& name, const std::vector<Menu> subMenus): name(name), subMenus(subMenus){}

takes two parameters.

int main(){
{
SportsClothingMenu();
}

SportsClothingMenu() is the constructor of class SportsClothingMenu. you can not call it in main(). Rather, you should instantiate an object of class SportsClothingMenu.

ok do you see this code relevent if i need to implement a menu such as

ok do you see this code nessary as i need to create a menu for a catalouge


Catalouge"
1.Shoes
2.Shirts
3.Adds a catagory
4.Adds a selling item
5.Quit

and i need to store the items into a binary tree

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.