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
JeffLemon
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook
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
Please use plain text.
Super Contributor
JeffLemon
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook

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
Please use plain text.
Developer
simon_hain
Posts: 16,134
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

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
Please use plain text.
Super Contributor
JeffLemon
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook

Re: Private Function

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

Re: Private Function

[ Edited ]

Your method definition has to have a namespace.

 

void App::setupPages() {

}

Like all of my posts
Please use plain text.
Super Contributor
JeffLemon
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook

Re: Private Function

I've changed my method to:

 

void App::setPages() {

{

}

 

Still no luck.

--------------------------------------------------------------------------------------------------
BlackBerry Apps: Instruments | ARTPAD | Piano | Drums | Xylophone
Please use plain text.
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

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
Please use plain text.
Super Contributor
JeffLemon
Posts: 440
Registered: ‎01-13-2011
My Device: Playbook

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
Please use plain text.