|
why need we doubly and simply?
and?
Logic is based on one algorithm or?
why are we checking also
if (n%4==0)
DoublyMagicSquare
else
SimplyMagicSquare
??
|
|
|
|
|
You found an article, have questions about it, and you couldn't find the forum that is under the article ( for discussing it ), or the right forum for C++ questions ?
Christian Graus - C++ MVP
|
|
|
|
|
You forgot... "Good luck"
led mike
|
|
|
|
|
I have a fairly big memory leak involving inherited classes.
The base class is a generic visual component which has data members used to create a basic window. The next class up is a generic Edit Window with no data members (it justs set values from the base class). The 3rd class in the heirachy is an simple Edit Window which contains data members for a simple edit (similar to the "Edit" class supplied by windows.
I noticed the leak whilst writing a program for work. So I decided to test it out a bit more thoroughly. I ended up with a loop which created and deleted 1000 of these Edit windows. To my horror I had a leak of over 600 bytes! I then tried making the destructors virtual, but this made no difference.
The classes look roughly like this:
AGenericWindow:
{
AGenericWindow();
virtual ~AGenericWindow();
HINSTANCE _hInstance;
HWND _hWnd;
WNDCLASSEX _wndClassEx;
AComponent* _pParent;
char _className[25];
int _resourceId;
};
AGenericEdit
{
AGenericEdit();
virtual ~AGenericEdit();
};
ASimpleEdit
{
ASimpleEdit();
virtual ~ASimpleEdit();
BOOL Disabled;
BOOL Number;
char* Text;
int TextAlign;
int TextLen;
};
I then tried making a fake heirachy which contained data at each level - using the same 1000x loop seems to deallocate all the memory fine!
I'm compliling with Visual C++ 6.0 on Windows XP. If anyone has any suggestions I would be very gratefull indeed!
Barney G Rubble
|
|
|
|
|
BarneyGRubble wrote:
I'm compliling with Visual C++ 6.0 on Windows XP.
Which means you're not using Managed C++, or C++/CLI, and so you are in the wrong forum...
BarneyGRubble wrote: char* Text;
BarneyGRubble wrote: AComponent* _pParent;
These pointers should be initialised to NULL. I'd guess if you did this, the 'leak' would go away.
Christian Graus - C++ MVP
|
|
|
|
|
Christian Graus wrote: These pointers should be initialised to NULL. I'd guess if you did this, the 'leak' would go away.
|
|
|
|
|
guys, i'm stuck on a wierd problem.
i've a class (say, Derived) which inherits from a 3rd prty class (Base). there are a set of virtual methods in the 'Base' that i override in my specialization. i built it as an application, and my 'Derived' objects ARE working fine.
the catch is when i build my app as a service. (i derived managed 'ServiceBase' before, but now i derives from CNTService, so that everything is unmanaged). now, this 'Derived' objects' virtual method invocations trigger the 'Base's implementations! it took me sometime to figure this out. these derived objects are even statically typed (i mean it is a Derived& which actually is a Derived&). the class lib i mentioned have their class (Base's) header shipped along with their libs. I've seen the declaration of the members as virtual. another point is that these methods are all callbacks. (events like CSocket::OnAccept() Onsend() etc, in fact, the 'Base' is a socket implementation). i never have to make any explicit calls to these methods. they are all triggered by the framework(Base's vendors') i'm using. may be (i'm almost sure) the internal callback implementation is done via c-style fptrs on some other tricks. but what i'm confused is the SAME 'Derived' do work perfectly in the application (but, NOT in the service). this is where i'm burning my head.
pls help me out with a fix for this.
any help / comments would really be appreciated.
thanks!!
snexxxxt
|
|
|
|
|
I have developed many services and never seen this occur. Is the library you are using a "managed" library or native?
led mike
|
|
|
|
|
|
snxxxxt wrote: unmanaged lib
Ok, well I am lost know. This is the C++/CLI forum and I cannot find a question from you that is related to doing managed development with VC++. Perhaps you could clarify?
led mike
|
|
|
|
|
can anybody help me in implementing blowfish algorithm in c/c++ for encryption/decryption between client and server in unix enviornment.
i dont have a clue how to do it..
-- modified at 15:19 Thursday 16th November, 2006
|
|
|
|
|
|
omc79 wrote: unix enviornment.
Then why would you ask in this forum ?
Christian Graus - C++ MVP
|
|
|
|
|
Hi ,friends
I got need make databse by c++.Anybaody could give any help? Thanks!
bt
|
|
|
|
|
Please be more specific. Do you want to access a database? There are many brands and types of databases! Do you want to actually make a database from scratch or just create tables and what not? Could you give more help?
gj
|
|
|
|
|
i need creating a database myself,i need make a database from scratch , can u give me some help please?
ert
|
|
|
|
|
Why make a database when you can obtain free or shareware databases. Also, there are all kinds of databases such as relational, identity relational, xml and object based. Anyway, you are not going to get much help here because you are not specific. Creating a database from scratch is a great endeavor.
|
|
|
|
|
Thanks for u to trying to help me. i just got the project from the college about using c++ to make database application. i really have no idea even how to start it,just want to do some research first. I hope i could get any information for it. thanks !
ert
|
|
|
|
|
Are you creating a database, or using one ? Are you using the .NET framework to do it, or are you asking in the wrong forum ?
Christian Graus - C++ MVP
|
|
|
|
|
Thanks for u to trying to help me. i just got the project from the college about using c++ to make database application. i really have no idea even how to start it,just want to do some research first. I hope i could get any information for it. thanks !
ert
|
|
|
|
|
OK, well, a good start is to answer my questions. I can't comment further without your answer. Are you using C++ with .NET or are you in the wrong forum. Do you need to make an app that uses a database, or do you need to write a database engine ? If the former, what are you allowed to use ( Access/Oracle/SQL Server/ MySQL/ etc ? )
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
|
This is the OnPaint function in my progressbar-class:
virtual void OnPaint(System::Windows::Forms::PaintEventArgs^ e) override
{
Graphics^ g = e->Graphics;
SolidBrush^ brush = gcnew SolidBrush(progressBarColor);
float percent = (float)(value - minimum) / (float)(maximum - minimum);
Rectangle rect = this->ClientRectangle;
// Calculate area for drawing the progress.
rect.Width = (int)((float)rect.Width * percent);
// Draw the progress meter.
g->FillRectangle(brush, rect);
// Creating font for progresstext
System::Drawing::Font^ drawFont = this->Font;
// Creating brush
System::Drawing::Brush^ drawBrush = System::Drawing::Brushes::Black;
// Creating string format
System::Drawing::StringFormat^ strFormat = gcnew System::Drawing::StringFormat();
// Center text
strFormat->Alignment = StringAlignment::Center;
strFormat->LineAlignment = StringAlignment::Center;
// Drawing string on top of progressbar
g->DrawString(this->percentCompletedText,drawFont,drawBrush,this->ClientRectangle,strFormat);
// Draw a border around the control.
DrawBorder(g);
// Clean up.
delete brush;
// Can not use despose Graphics object when using DoubleBuffer
//delete g;
}
Now my progressbar have a percent completed written over it in black all the time. How do i get the color of the text to change or invert when the progressbar passes over it?? I have been looking around on the web for this task but I can't find other then MFC code in native C++. How is it done with managed C++ or C#??
|
|
|
|
|
In exactly the same way - work out what portion of the bar is covering the text, and draw that text with a different color.
Christian Graus - C++ MVP
|
|
|
|
|
How do I draw half a word (my percent completed for example) in a different color???
How do I get the invert effect??
|
|
|
|