|
Yeah...I have WS_VISIBLE selected.
./[tiller]
|
|
|
|
|
I have a member variable of a class declared as a pointer to type double, m_dHessianMatrix . This variable will be holding a 2 x 2 matrix (could be larger)and needs to be initialized completely to zeroes to start. As such, I need something to init the matrix to zero quickly (thus a for loop will not do particularly for LARGE matrices).
Currently I am initializing the matrix data in the constructor as follows:
CROT_Optimizer::CROT_Optimizer(UINT MaxNodes)
{
ASSERT (MaxNodes > 0);
if (MaxNodes == 0)
return;
m_uiNumberOfNodes = MaxNodes;
m_uiNumberOfSprings = 0;
m_ppNodeIndexedSpringArray = NULL;
m_dHessianMatrix = NULL;
m_dHessianMatrix = new double[4];
memset(m_dHessianMatrix, 0, sizeof(double));
}
However, I don't like this for two reasons.
1.) I have to include string.h to gain access to the memset function ->code bloat
2.) It is not aesthetically pleasing to the eye
Is there a way to initialize the matrix without using a for loop and without using memset() ?
|
|
|
|
|
|
Ah, ok. One question.
If I have a 4 element matrix, is the proper syntax:
ZeroMemory(&m_dHessianMatrix, sizeof(double));
<pre><code>
ZeroMemory(&m_dHessianMatrix, 4*sizeof(double));
?
(Thanks for the suggestion)
|
|
|
|
|
ZeroMemory(&m_dHessianMatrix, 4*sizeof(double));
John
|
|
|
|
|
What functions/classes should I use for thread syncronization inside a module that is used in both ATL and MFC projects?
-Alma-
|
|
|
|
|
Use the win32 API. CreateEvent(), CreateMutex() ...
John
|
|
|
|
|
Yeah, right!
Thanks!
-Alma-
|
|
|
|
|
Hi all,
How can i create an abstract class without using virtual keyword in c++.
Mahesh
|
|
|
|
|
You can't.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
"You won't like me when I'm angry..." - Dr. Bruce Banner
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
??? If you use inherance overloading without virtual you will run into trouble.
If you want to avoid virtual methods, use template meta programming.
Jonathan de Halleux.
|
|
|
|
|
Is there a particular reason you don't want to use virtual ?
- Mike
|
|
|
|
|
I was thinking the same.
John
|
|
|
|
|
Hi Mike,
Thanks.. No particular reason mike. It was an interview question.
I just want to confirm whether it is possible.
Mahesh
|
|
|
|
|
You can't - an abstract class is defined as having at least one method be virtual and not having an implementation. e.g.,
class VirtualClass
{
public:
virtual void OverrideMe() = 0;
};
A compiler won't let you instantiate such a class. If you can instantiate it, then it is not an abstract class.
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity." - Albert Einstein
|
|
|
|
|
We can prevent the instantiation of the class by making it's constructors private, however the problem with this is that the class cannot be derived then.
|
|
|
|
|
Just a thought... did you have the __declspec(novtable) extension in mind?
If so, keep in mind that the novtable attribute does not semantically mark the class as abstract; rather, it just removes the vtable initialization code. It just happens that this is most useful for application to abstract classes.
- Mike
|
|
|
|
|
Hi,
Im writing 2 programs in VC++6 that broadcast messages to each other. One is a full blown windows program, complete with message map and handles incoming messages perfectly. The second however is a small console program, consisting of int main() and 1 global function. All of the examples i have seen implement the message map in dialog classes. Is it possible to implement it globally like shown below?
MESSAGE_MAP()
....
void GotAMessageWooYay()
{
...
}
int main()
{
...
}
|
|
|
|
|
How are you going to broadcast messages to the console application?? I think you need at least a hidden window there. Unless you send thread messages.
John
|
|
|
|
|
I agree, messages are sent through the winproc, and if there is no window, there is no proc.
|
|
|
|
|
Does anyone know how to get around the 31 character limit in IStorage::CreateStorage and IStorage::CreateStream?
I am trying to use the IMAPI functions to programmatically burn data to a cd which I have been able to do successfully, however, I can't seem to get around the 31 character limit when trying to burn a file whose name exceeds 31 characters.
Any suggestions?
|
|
|
|
|
Hi,
I have two dialog boxes, the first one is a normal one with the default buttons ok and cancel, while the second has a ok and a combobox.
The program is supposed to work like this.
When a person clicks ok in the first dialog box, the program takes the "DEFAULT" values and does some job . if cancel is clicked, the second dialog box is opened and some data is chosen from the combobox and takes this value and does the same job.
when the job is done the application is closed,
Now when I open the application once again, I want the last chosen value from the combobox to be set as the "DEFAULT" values . Is there a specific way to do this..
Can anyone suggest me ways as to how to proceed..
Thanks.
Deepak Samuel
|
|
|
|
|
Get the selected item # of the combobox and save it in the registry using AfxGetApp()->WriteProfileInt(). Get it back using AfxGetApp()->GetProfileInt().
John
|
|
|
|
|
Look up history combo here at code project.. Should be in the combo & list box section.. It will do what you want..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Thanks for reminding me of that. I remember that is a good implementation so better not reinvent the wheel...
John
|
|
|
|