Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Moving class declaration from .cpp file to .h file

Reply
Thread Tools

Moving class declaration from .cpp file to .h file

 
 
yinglcs@gmail.com
Guest
Posts: n/a
 
      01-15-2007
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;
};

 
Reply With Quote
 
 
 
 
Wang Dong
Guest
Posts: n/a
 
      01-16-2007
Just move it, nothing will go wrong but any inlilne func must keep in .h if
want it inline still.

<(E-Mail Removed)>
??????:(E-Mail Removed) 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;
> };
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free Moving Estimate, Local Movers, Long Distance Moving, PackingSupplies, Storage Rental, Home Moving, Apartment Moving, Office Moving,Commercial Moving linkswanted ASP .Net 0 01-06-2008 04:45 AM
maxplusII error: a deferred constant declaration without a full declaration is not supported Noah VHDL 5 04-07-2006 02:34 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
"virtual outside class declaration" and "declaration does not declare anything" kelvSYC C++ 6 05-17-2005 08:58 AM
Function declaration in class declaration Ovidesvideo C++ 4 12-10-2004 06:36 PM



Advertisments