Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Parent-Child question

Author
Message
Yogz
19
Years of Service
User Offline
Joined: 11th Oct 2004
Location: England
Posted: 14th Jan 2008 23:45
Can a child module, i.e. a .cc source file, call a function in a parent program, i.e. the main .cpp program?

If so what do I need to do?
(without arsing around with inheritance if possible)

Ta
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 14th Jan 2008 23:54
Make a .h file and declare all your functions, and make a .cpp file with the same name (well, unless you dont want to), include the .h, and define the functions.

When you want to call the functions, just include the .h

Your signature has been erased by a mod
Yogz
19
Years of Service
User Offline
Joined: 11th Oct 2004
Location: England
Posted: 14th Jan 2008 23:58
I figured that as you posted - C++ is very fussy in that everything has to be in a set order, ie the function I was calling obviously appeared below the preprocessor commands - which placed it after the function call - but it couldn't be identified because the compiler hadn't encountered it.

As you say, solution - bang function in header file and include before the .cc file is included.

Thanks

Login to post a reply

Server time is: 2024-10-08 15:49:07
Your offset time is: 2024-10-08 15:49:07