Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA
Accepted Solution

Private Function

I want a private function in my app.cpp. I don;t want to declare it in the header file, is there a way to do this?

 

So far I have got, but it doesnt work:

 

App::App()
{

	setMenu();

}


void setMenu()
{

}

 

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

Re: Private Function

So I've tried a few things and now have this in my header:

 

private:
void setPages();

 

 

And this in my main:

 

App::App()
{
setPages();
}

void setPages()
{
}

 I get the error:

 

Description Resource Path Location Type
undefined reference to `App::setPages()' app.cpp /appone/src line 22 C/C++ Problem

 

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Developer
Posts: 17,011
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Private Function

try App:setPages(){}
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

Re: Private Function

Nope, doesn't work.
--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Private Function

[ Edited ]

Your method definition has to have a namespace.

 

void App::setupPages() {

}

Like all of my posts
Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

Re: Private Function

I've changed my method to:

 

void App::setPages() {

{

}

 

Still no luck.

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Private Function

You say you have the method definition in App.h

 

then you say you are calling it from main. Does that mean App.cpp?

Like all of my posts
Super Contributor
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
My Carrier: NA

Re: Private Function

Sorry, this does work, I had commented the declaration in the header file whilst testing something else.

 

void App::setPages()

 

Thanks!

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone