Moving class declaration from .cpp file to .h file

Y

yinglcs

I find the following class declaration in a .cpp file.
If I need to move it to .h file so that other class can include that .h
file and see this class,
do I need to move all the implementation of all the code back to .cpp?
Things like 'Constructor', 'Destructor', inline method, non-inline
method?

Thank you.

class nsCanvasPattern : public nsIDOMCanvasPattern
{
public:


nsCanvasPattern(cairo_pattern_t *cpat, PRUint8 *dataToFree)
: mPattern(cpat), mData(dataToFree)
{ }

~nsCanvasPattern() {
if (mPattern)
cairo_pattern_destroy(mPattern);
if (mData)
nsMemory::Free(mData);
}

void Apply(cairo_t *cairo) {
cairo_set_source(cairo, mPattern);
}

inline void Clear() {
mPattern->clear();
}

protected:
cairo_pattern_t *mPattern;
PRUint8 *mData;
};
 
W

Wang Dong

Just move it, nothing will go wrong but any inlilne func must keep in .h if
want it inline still.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top