#include <afxwin.h>
#include "resource.h"
class yyy:public CFrameWnd
{
public :
CMenu *m;
yyy()
{
m=new CMenu;
Create(0,"Hell0");
m->LoadMenu(IDR_MENU1);
SetMenu(m);
}};class zzz:public CWinApp
{
public :
zzz()
{
yyy *a;
 a=new yyy;
 m_pMainWnd=a;
 a->ShowWindow(SW_SHOWMAXIMIZED);
}
};zzz a;

解决方案 »

  1.   

    m=new CMenu;
    m.Create(0,"Hell0");
      

  2.   

    不行我试了,有错误,你试了没?
    error C2228: left of '.Create' must have class/struct/union type
    Error executing cl.exe.
      

  3.   

    CMenu m;//定义一个对象,不要用指针
      

  4.   

    D:\C-PPT-V1.0\TP\xx\f.cpp(9) : error C2582: 'CMenu' : 'operator =' function is unavailable
    D:\C-PPT-V1.0\TP\xx\f.cpp(10) : error C2039: 'Create' : is not a member of 'CMenu'
            c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1080) : see declaration of 'CMenu'
    D:\C-PPT-V1.0\TP\xx\f.cpp(11) : error C2819: type 'CMenu' does not have an overloaded member 'operator ->'
            c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1080) : see declaration of 'CMenu'
    D:\C-PPT-V1.0\TP\xx\f.cpp(11) : error C2227: left of '->LoadMenuA' must point to class/struct/union
    D:\C-PPT-V1.0\TP\xx\f.cpp(12) : error C2664: 'SetMenu' : cannot convert parameter 1 from 'class CMenu' to 'class CMenu *'
            No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    Error executing cl.exe.xx.exe - 5 error(s), 0 warning(s)
    也不行
      

  5.   

    CMenu m;//定义一个对象,不要用指针
    是错的m=new CMenu;
    m->Create(0,"Hell0");