Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Moving class declaration from .cpp file to .h file (http://www.velocityreviews.com/forums/t459846-moving-class-declaration-from-cpp-file-to-h-file.html)

yinglcs@gmail.com 01-15-2007 07:58 PM

Moving class declaration from .cpp file to .h file
 
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;
};


Wang Dong 01-16-2007 01:30 AM

Re: Moving class declaration from .cpp file to .h file
 
Just move it, nothing will go wrong but any inlilne func must keep in .h if
want it inline still.

<yinglcs@gmail.com>
??????:1168891104.829796.268330@11g2000cwr.googleg roups.com...
>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;
> };
>





All times are GMT. The time now is 06:41 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.