CMenu menu; menu.CreateMenu(); // Create a menu menu.AppendMenu(MF_STRING, IDM_FILE_NEW, _T("&New")); // Add a "New" option to the menu CMenu* pSubMenu = new CMenu; pSubMenu->CreatePopupMenu(); // Create a submenu pSubMenu->AppendMenu(MF_STRING, IDM_FILE_SAVE, _T("&Save")); pSubMenu->AppendMenu(MF_STRING, IDM_FILE_SAVEAS, _T("Save &As")); menu.AppendMenu(MF_POPUP, (UINT_PTR)pSubMenu->m_hMenu, _T("&File")); // Attach the submenu to the menu bar CWnd* pWnd = AfxGetMainWnd(); // Get the main window handle pWnd->SetMenu(&menu); // Set the constructed menu to the main windowThis code creates a menu and a submenu with "New", "Save" and "Save As" options. It then attaches the submenu to the "File" option in the main menu bar and sets the menu to the main window. CMenu Attach is part of the MFC (Microsoft Foundation Class) library in C++.