About Store Forum Documentation Contact
Donations:
392$/mo



Post Reply 
error in use button::func()
Author Message
Babulesnik Offline
Member

Post: #1
error in use button::func()
I have a error:
Code:
error C3867: 'StructEventsButtons::BtnMenu': function call missing argument list; use '&StructEventsButtons::BtnMenu' to create a pointer to member

Header code:
Code:
struct StructEventsButtons
{
    StructMenuMain MenuMain;
    
    void BtnMenu(Ptr){MenuMain.warning(true);}

    void init    ( GuiObjs &BowlingGui  );
    
private:
    GuiObjs *PtrBowlingGui;
};

Source code:
Code:
void StructEventsButtons::init( GuiObjs &BowlingGui )
{
    PtrBowlingGui = &BowlingGui;
    PtrBowlingGui -> getButton( "menu" ).func(BtnMenu);
}
10-28-2011 01:32 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #2
RE: error in use button::func()
If the function is in a struct or class, it must be declared static:

Code:
static void BtnMenu(Ptr) {}
10-28-2011 05:32 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #3
RE: error in use button::func()
(10-28-2011 05:32 PM)Driklyn Wrote:  If the function is in a struct or class, it must be declared static:

Code:
static void BtnMenu(Ptr) {}

Thanks,but the new error:
Code:
error C2228: left of '.main' must have class/struct/union

*.h
Code:
struct StructEventsButtons
{
    StructMenuMain MenuMain;

    static void BtnMenu(Ptr);

    void init    ( GuiObjs &BowlingGui  );
    
private:
    GuiObjs *PtrBowlingGui;
};

*cpp
Code:
void StructEventsButtons::BtnMenu(Ptr)
{
    MenuMain.main(true);
}
void StructEventsButtons::init( GuiObjs &BowlingGui )
{
    PtrBowlingGui = &BowlingGui;
    PtrBowlingGui -> getButton( "menu" ).func(BtnMenu);
}
(This post was last modified: 10-28-2011 08:04 PM by Babulesnik.)
10-28-2011 08:04 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #4
RE: error in use button::func()
MenuMain will also have to be static; that, or declare MenuMain outside of the struct.
10-29-2011 12:00 AM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #5
RE: error in use button::func()
(10-29-2011 12:00 AM)Driklyn Wrote:  MenuMain will also have to be static; that, or declare MenuMain outside of the struct.
This variant works " or declare MenuMain outside of the struct " , but how to make by the first variant "MenuMain will also have to be static" ? -there is an error:
Code:
error LNK2001: unresolved external symbol "public: static struct StructMenuMain StructEventsButtons::MenuMain" (?MenuMain@StructEventsButtons@@2UStructMenuMain@@A)

*.h
Code:
struct StructEventsButtons
{
    static StructMenuMain MenuMain;

    static void BtnMenu(Ptr){MenuMain.main(true);}

    void init    ( GuiObjs &BowlingGui  );
    
private:
    GuiObjs *PtrBowlingGui;
};

*.cpp
Code:
void StructEventsButtons::init( GuiObjs &BowlingGui )
{
    PtrBowlingGui = &BowlingGui;
    PtrBowlingGui -> getButton( "menu" ).func(BtnMenu);
}
10-29-2011 02:54 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #6
RE: error in use button::func()
Show the code for StructMenuMain. Where are you declaring/including it?
10-29-2011 11:40 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #7
RE: error in use button::func()
(10-29-2011 11:40 PM)Driklyn Wrote:  Show the code for StructMenuMain. Where are you declaring/including it?

bowling.h
Code:
#include "Chat.h"
#include "BowlingLib.h"

bowlinglib.h
Code:
struct StructMenuMain
{
    void init    ( GuiObjs &BowlingGui  );
    void warning ( Bool visible         );
    void main    ( Bool visible         );

private:
    GuiObjs *PtrBowlingGui;
};
/********************************************************************************​*/

/**************************EventsButtons"**********************************/
struct StructEventsButtons
{
    static StructMenuMain MenuMain;

    static void BtnMenu(Ptr);

    void init    ( GuiObjs &BowlingGui  );
    
private:
    GuiObjs *PtrBowlingGui;
};

bowlinglib.cpp
Code:
#include "stdafx.h"
#include "Bowling.h"
void StructMenuMain::init( GuiObjs &BowlingGui )
{
    PtrBowlingGui = &BowlingGui;

    {
        Flt width  = PtrBowlingGui -> getWindow( "warning" ).rect.w();
        Flt height = PtrBowlingGui -> getWindow( "warning" ).rect.h();
        PtrBowlingGui -> getWindow( "warning" ).pos(Vec2( (D.w()-D.w())-(width/2) ,D.h()-D.h()+height ));
    }
    {
        Flt width  = PtrBowlingGui -> getWindow( "main" ).rect.w();
        Flt height = PtrBowlingGui -> getWindow( "main" ).rect.h();
        PtrBowlingGui -> getWindow( "main" ).pos(Vec2( (D.w()-D.w())-(width/2) ,D.h()-D.h()+height ));
    }
    
    
    T.warning(false);
    T.main   (false);
}
void StructMenuMain::warning( Bool visible )
{
    PtrBowlingGui -> getWindow( "warning" ).visible(visible);
}
void StructMenuMain::main( Bool visible )
{
    PtrBowlingGui -> getWindow( "main" ).visible(visible);
}
/********************************************************************************​*/

/**************************"EventsButtons"******************************/
void StructEventsButtons::BtnMenu(Ptr)
{
    MenuMain.main(true);
}
void StructEventsButtons::init( GuiObjs &BowlingGui )
{
    PtrBowlingGui = &BowlingGui;
    PtrBowlingGui -> getButton( "menu" ).func(BtnMenu);
}
(This post was last modified: 10-30-2011 04:33 PM by Babulesnik.)
10-30-2011 04:30 PM
Find all posts by this user Quote this message in a reply
Post Reply