473,320 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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;
};

Jan 15 '07 #1
1 1762
Just move it, nothing will go wrong but any inlilne func must keep in .h if
want it inline still.

<yi*****@gmail.com>
??????:11**********************@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;
};

Jan 16 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Stephane Routelous | last post by:
Hi, I would like to make a forward declaration of a strcuture nested in a class. I have file A.h class A { public: struct B
2
by: Ruben Campos | last post by:
I have a problem with a template function that is declared as a friend of a template class. I'll first show the exact problem with source code: // MyClass.hpp template <typename T> class...
2
by: Jessica | last post by:
I have a base class and a derived class, but I am getting errors when I try to access functions of the derived class. Simplified version of my code is as follows: //////////////// // test2.hh...
17
by: Amchi | last post by:
Alright .... this makes no sense ... Declared a class 'diskStorage' in a header ...diskStorage.h Defined it's contructor and methods ... in diskStorage.cpp Included diskStorage header in...
4
by: zfareed | last post by:
#include <iostream> #include <fstream> using namespace std; template<class ItemType> class SortedList { private:
4
by: =?Utf-8?B?R1Q=?= | last post by:
I have a Form which has a great number of events. I thought I would organize the project by moving some of the code into multiple '.cs' files (since the Form.cs was getting huge). When I move them,...
9
by: Jess | last post by:
Hello, I was told that if I declare a static class constant like this: class A{ static const int x = 10; }; then the above statement is a declaration rather than a definition. As I've...
1
by: Angus | last post by:
Why moving a function from protected to public area in class causes error C2556 - overloaded function differs only by return type I have a protected function called GetState like this: enum...
15
by: akomiakov | last post by:
Is there a technical reason why one can't initialize a cost static non- integral data member in a class?
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.