|
I am just wondering if this:
class Vector
{
public:
float x,y,z;
};
Vector v;
differs from this:
class Vector
{
public:
float x,y,z;
void Cross(Vector, Vector);
void Dot(Vector, Vector);
void Normalize();
};
Vector v;
in terms of performance.
modified on Friday, June 4, 2010 1:56 PM
|
|
|
|
|
What do you mean by "performances" ? If you mean memory size (which I guess you mean because speed is irrelevant here): there's little difference between the two. The methods of a class are in fact not contained in each instance of the class (which means that if you instantiate 10.000 classes, the methods in the class won't have a big impact on the memory consumption).
Does that answer your question ?
|
|
|
|
|
what's the question ?
performance is dependant on a whole lot of different factors!
memory usage ? computation speed ?
AFAIK, adding member function to a class does not really impact on performance.
Watched code never compiles.
|
|
|
|
|
If you mean does implementing operations on a class as member functions add any overhead to the time it takes to execute those operations compared to an equivalent global function then the answer is no.
If you use virtual functions then there's a bit of additional overhead but it's pretty minimal compared to dividing two floating point numbers.
Cheers,
Ash
|
|
|
|
|
Hey all,
the project I'm currently working on at one point generates several files with specific information in them. What I want to try and do is wrtie to the file properties after generating that file.
ie, right click on a (.txt) file -> properties -> summary
I want to be able to write to the author, keyword....etc... fields listed in that tab. I'm guessing that this can be done with a strig??? but I don't know if there's a MSDS function that allows for this or the proper way to access the information. All of this information (author, keywords and comments) is already stored in structs and arrays. I also already have access to the address of its base location.
idears?
obtw, looks like a good forum, looking for a good response from the first post
modified on Friday, June 4, 2010 12:09 PM
|
|
|
|
|
This[^] CodeProject article could be very useful for you.
|
|
|
|
|
litteraly just found that. Sorry and thanks!
|
|
|
|
|
Hi, im using Radio button to display status of state.
Like State0,State1,State2...
But,user should not click the radio button.
So i make all radio button to disabled,but its look in dull and white colr.
I dont want that.
How can i get that feature ?
Anu
|
|
|
|
|
Well, there is a point in keeping a disabled control looking disabled.
That said, you can handle WM_LBUTTONDOWN in your radio buttons and short-circuit the click from the user.
Edit: Language
|
|
|
|
|
Hey.
Was my first thought too but as it seems, WM_LBUTTONDOWN alone isn't enough since the user can also use the keyboard to tab to the control and then hit SPACE to check it. It helps somewhat if you remove the WS_TABSTOP style but then he can still doubleclick the radio (WM_LBUTTONDBLCLK) which magically sets the focus on the radio and again, he can use SPACE to check it...
Imho the best thing is to also handle some other messages, see here[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
Create your own CButton class, in it, handle the following messages:
WM_LBUTTONDOWN -> void OnLButtonDown(UINT nFlags, CPoint point)
WM_LBUTTONUP -> void OnLButtonUp(UINT nFlags, CPoint point)
WM_LBUTTONDBLCLK -> void OnLButtonDblClk(UINT nFlags, CPoint point)
WM_KEYDOWN -> void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
WM_KEYUP -> void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
WM_CHAR -> void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
In each of these functions, do nothing, don't call the super versions either. Don't know how failsafe it is, but seems to be working for me. Good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
Ah! Forgot about the keyboard. I always do
|
|
|
|
|
Haha, we just "cross-posted[^]" each other.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
|
Ofcourse im using all this functionalities in that dialog class for someother features.
Anu
|
|
|
|
|
Pardon?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
In that dialog class..Im using mouse lcick functional;ities and Key up and down functionalites to get another function like to invoke another view by mouse clcik or short cut key.
But i dont know how to stop to enter(click value of radio button) in dialog .
Anu
|
|
|
|
|
Derive a class from CButton, handle those messages in this derived class and use it for your radio.
Something like this:
CReadOnlyRadio: public CButton
{
public:
DECLARE_MESSAGE_MAP()
void OnLButtonDown(UINT nFlags, CPoint point) { }
void OnLButtonUp(UINT nFlags, CPoint point) { }
void OnLButtonDblClk(UINT nFlags, CPoint point) { }
void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { }
void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) { }
void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { }
};
...
BEGIN_MESSAGE_MAP(CReadOnlyRadio, CButton)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_LBUTTONDBLCLK()
ON_WM_KEYDOWN()
ON_WM_KEYUP()
ON_WM_CHAR()
END_MESSAGE_MAP()
...
class CMyFancyDialog: public CDialog
{
...
DoDataExchange(CDataExchange* pDX);
CReadOnlyRadio m_ReadOnlyRadio;
...
};
...
void CMyFancyDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
...
DDX_Control(pDX, IDC_READONLY_RADIO, m_ReadOnlyRadio);
...
}
...
Hope it is understandable...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
The only issue is you probably don't want to declare the member variable in the constructor. That should be in the header file for the class or, in this case, where you have all of those empty methods.
|
|
|
|
|
Declare the variable in the constructor? What do you mean?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
What I mean is you have :
CReadOnlyRadio m_ReadOnlyRadio;
in the constructor of the dialog class.
|
|
|
|
|
class CMyFancyDialog: public CDialog
{
...
DoDataExchange(CDataExchange* pDX);
CReadOnlyRadio m_ReadOnlyRadio;
...
};
-this is the ("pseudo"-)declaration of the class, not its constructor.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
Hi,
I am using ProC code in my 64 bit application.
i am getting the following error while building it:
error LNK2001: unresolved external symbol sqlcxt
I have added extern"C" in sqlcxt definition.
extern "C"
{
void sqlcxt (void **, unsigned int *,
struct sqlexd *, const struct sqlcxp *);
void sqlcx2t(void **, unsigned int *,
struct sqlexd *, const struct sqlcxp *);
void sqlbuft(void **, char *);
void sqlgs2t(void **, char *);
void sqlorat(void **, unsigned int *, void *);
}
Does any one has any idea why I am getting this?
|
|
|
|
|
What you're getting is a linker error.
This can be fixed by referencing the library in which sqlcxt etc. are implemented.
|
|
|
|
|
I am linking to orasql9.lib.
Can u tell me which library I have to link?
Actually this is working fine for 32 bit application.
But for 64 bit i am getting this error.
Please Help......
|
|
|
|