Skip to main content
gamedev.net
🔒 Locked

Function Returning a Pointer

Started by UBC_Wiskatos Apr 9, 2002 at 5:30 PM 2 replies 300+ views
Original Post
UBC_Wiskatos
UBC_Wiskatos
I have a structure called SBMPFont, and a class method (of COutputEngine) that is called LoadFont. What is the proper syntax for a class method that returns a pointer to SBMPFont. Is it *SBMPFont LoadFont(blah); and *SBMPFont COutputEngine::LoadFont(blah) or is it something else? Basically, what I have is a method that will dynamically allocate memory for a font and initialize it, then return a pointer to the newly created font (that is of the structure SBMPFont). [edited by - UBC_Wiskatos on April 9, 2002 6:32:13 PM]
[email=ubc_wiskatos@hotmail.com" target="_blank" style="width: 10px; height: 10px; background: #fe7a21; overflow: hidden; display: block; margin-bottom: 2px;][/email]
IndirectX
IndirectX

class C {
Stuff *CreateStuff();
};

Stuff *C::CreateStuff()
{
return new Stuff;
}


[edited by - IndirectX on April 9, 2002 6:34:14 PM]
---visit #directxdev on afternet <- not just for directx, despite the name
siaspete
siaspete
SBMPFont * LoadFont (blah);

You might want to add a function to delete the font too. Fair enough that it''s probably just a "delete" operator, but I think things should mostly be deleted by the same object that created them.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
UBC_Wiskatos
UBC_Wiskatos
Thanks guys! It work really well now. :-)

siaspete: Yep, I also have a method to delete the font.
[email=ubc_wiskatos@hotmail.com" target="_blank" style="width: 10px; height: 10px; background: #fe7a21; overflow: hidden; display: block; margin-bottom: 2px;][/email]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.