|
I made a little test project just to try this all out before actually implementing it in my own project. I created a separate header file that contains all my structures, and also this new copy constructor stuff. I have included this header file in CMainFrame. I'm getting link errors now when I compile, I looked everywhere for information on these errors yesterday and have come to the conclusion that things are being linked in the wrong order or something, but I wasn't able to actually fix the problem. This is what my new header file looks like (we'll call it MyStructures.h):
#include "afxtempl.h"
#include "stdafx.h"
..other structs defined here...
struct INV
{
public:
INV(const INV& oldStruct);
INV();
INV& operator=( const INV &s );
int number;
CArray<COMPLEX, COMPLEX&> complexArray;
};
//INV constructor
INV::INV()
{}
// Copy constructor implementation
INV::INV( const INV& oldStruct )
{
number = oldStruct.number;
//copy the complex array here
}
//operator= implementation
INV& INV::operator= ( const INV &s )
{
number = s.number;
//copy the complex array here
return *this;
}
..other structs defined here...
these are the errors i'm getting:
MainFrm.obj : error LNK2005: "public: __thiscall INV::INV(void)" (??0INV@@QAE@XZ) already defined in CopyConstructorTest.obj
MainFrm.obj : error LNK2005: "public: __thiscall INV::INV(struct INV const &)" (??0INV@@QAE@ABU0@@Z) already defined in CopyConstructorTest.obj
MainFrm.obj : error LNK2005: "public: struct INV & __thiscall INV::operator=(struct INV const &)" (??4INV@@QAEAAU0@ABU0@@Z) already defined in CopyConstructorTest.obj
Debug/CopyConstructorTest.exe : fatal error LNK1169: one or more multiply defined symbols found
|
|
|
|
|
i seem to have fixed it now. i'm not sure if it's the correct solution, but it seems to work. all i did was move the INV constructor, copy constructor and operator= implementation into CMainFrame.
if that's not the right way to fix this problem, someone please let me know!
|
|
|
|
|
something completely different with your purpose, but, be careful on the names you give to your fields...
<font style="color:blue;">struct</font> COMPLEX {
CString original;
<font style="color:blue;">int</font> changed;
<font style="color:red;">CString new</font>;
};
new is a reserved name !!!
TOXCCT
|
|
|
|
|
toxcct wrote:
new is a reserved name !!!
yeah, i know that. That was actually just an example i had typed directly into this message board, i hadn't cut and pasted it. when i did it in my code, i used newStr instead. but thanks for picking up on that!
|
|
|
|
|
CArray is crap. You can certainly do this with vectors, vector being actual C++ as opposed to MFC overstretching it's limits.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
why some program when i compile it is not error but execute it the error ' debug assertion failed'....Is anyone can let me know what is the program!!!!!
|
|
|
|
|
We often use _assert, ATLASSERT, ASSERT or similar macros to check for certain conditions being true (or false). These will provide confidence that previous code has worked.
However, these are not evaluated at compile-time, but at run-time. If you use MFC, there are many common messages, and under the debugger, if you select 'Retry', it will take you to the assert that triggered. Often that is enough to help you work out what went wrong.
Steve S
|
|
|
|
|
I would like to add that some times ASSERT is applied in MFC when it would cause no problems, since the SDK method/function being called just returns with fialure/success value. Therefore, you should detemine if it realy is an error (are you checking return value).
Example:
Many methods/functions that take an HDC as an argument and will accept a NULL HDC (use screen DC instead).
For the most part MFC takes the above situation into account, but occationaly they did let a few through. In which case, the assert becomes an information only assert.
INTP
|
|
|
|
|
Hi!
I am currently trying to display small images in a dialog using a CStatic. I've created a static control in the dialog using the resource editor and set its style to SS_BITMAP. Then I created a variable for the static, m_stcImagePreview (type CStatic).
Then I tried to set the image using this code:
IMAGEINFO ii;
VERIFY(m_pParentImageList->GetImageInfo(m_nIconId, &ii));
m_stcImagePreview.SetBitmap(ii.hbmImage); It doesn't throw an assertion error, but unfortunately it also doesn't work... The image isn't displayed, it shows random crap. The m_pParentImageList is a pointer to the image list containing some 16x16 images, it is assured that m_nIconId is never greater than the image count.
Any idea what I am doing wrong?
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
I have an application with a single document; I use the doc/view architecture to manage the main views ( 3d views ), and I have a couple of other "views" ( not CView ) that display some data from the document.
When loading a document, I need to fill the other views ...
I'm not sure exactly where to do this.
I handle the void MyApp::OnFileOpen() to fill in the CFileDialog with a custom filter and extensions list, and call CWinApp::OpenDocumentFile (sPath);
void CBuild_itApp::OnFileOpen()
{
CWinApp::OpenDocumentFile (sPath);
FillInOtherViews();
}
I could add calls to the end of that method to fill in the other views, but it does not look kosher. I can also trigger a notification ( with observers that I already use elsewhere ) to make the other views handle themselves.
Any thoughts ?
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
I am doing a project on face facial detection and expression analysis
Presently, i have got the coordinates of the faces facial of both the eyes and the mouth
With these pts as output for a neutral expreeion, i can set control values group certain expression as happy or sad. e.g happy is seen by eyes smaller, smile wider.
how do i call these pts out again
|
|
|
|
|
Our application has RC Files for a couple of languages, and the framework loads the appropriate language according to OS version.
Though I would like to choose and change the language at run time.
Any clue?
-MyttO
|
|
|
|
|
Hello!
You may use:
1. LoadLibrary() along with AfxSetInstanceHandle() (for mfc app) on given resource dll (can be resource only but not must be)
2. You may try to use SetThreadLocale() and use only one resource dll with many resources, each defined for every language you may want to support. But SetThreadLocale is not supported under Windows9x
I propose to use 1st method.
|
|
|
|
|
I'm the second case, ie my dlls have resources defined in multiple languages.
I use SetThreadLocal() in InitInstance() with no error but resources are still loaded in OS Version language (working under Win2k)
Did i do something wrong?
-MyttO
|
|
|
|
|
Hello,
Can anyone help me how to load an extension dll explicitly or dynamically?
thanks..
sphynx
|
|
|
|
|
Either link with the import library (.lib) or use LoadLibrary()/GetProcAddress().
onwards and upwards...
|
|
|
|
|
Hello!
Use AfxLoadLibrary(). From MSDN:
"
Be sure to use AfxLoadLibrary and AfxFreeLibrary (instead of the Win32 functions LoadLibrary and FreeLibrary) if your application uses multiple threads and if it dynamically loads an extension DLL. Using AfxLoadLibrary and AfxFreeLibrary insures that the startup and shutdown code that executes when the extension DLL is loaded and unloaded does not corrupt the global MFC state.
"
and then use GetProcAddress() either by name, or by ordinal
|
|
|
|
|
I am working on a project in which we have to provide a UI to user in which all frames belonging to a selected mpeg2 video file are displayed. User then assign some attribute to each frame and then we have to store that video with those attributes added to each frame. Can any one give some idea about libraries or API's or controls which can help us.
|
|
|
|
|
Hello !
I'm facing a debugging problem: I have a class created dynamically (with new operator). When this object is deleted, an exception is thrown BUT, the destructor is called correctly and works fine, the error occurs after the last line of the destructor and before the next instruction in my program.
The error occurs at line 1062 in dbgheap.c (if that helps you).
So, my question is: how can I find the source of this error ?? The object is quite big and using memory window will be very a huge task...
Any idea ?
Thanks
|
|
|
|
|
hi guy,
the first thing that comes to my mind is that one :
isn't your class derived from one other?
if you forgot to specify the virtual keyword in such case, it must freeze...
TOXCCT
|
|
|
|
|
No, it isn't !
But I found the solution: I use the hard way. I comment almost all the code that has to deal with this class, then uncomment step by step and found at wich block of code the bug appear when the object is destroyed.
In fact I was writing something out of the bounds of a dynamically created array of my class and it doesn't fire an exception at this time neither when I destroy THIS array, but only when the object itself was destroyed.....
Uf, quite hard to find this one
|
|
|
|
|
Look in your CRT source code. C:\program files\Microsoft Visual Studio .NET 2003\vc7\crt\src for VC7.1, C:\program files\Microsoft Visual Studio\VC98\CRT\SRC for VC6.
Basically, it's telling you that one of your allocations went wrong. You may have freed the same block twice, or you may have overrun the allocation.
To help catch buffer overruns, you can enable page-level heap allocations in Windows. You can download the PageHeap tool as part of the Windows Application Verifier[^].
|
|
|
|
|
Thanks for reply but I found a solution (see previous post).
But thanks for the link !! I'll download this tool this will help me to catch further errors !
|
|
|
|
|
hi..
i have a problem here. I am making use of a tab control in a dialog box. Since I have 3 pages which all require edit boxes, i will need to have overlapping ones (in order to ensure that each tab page gets a edit box of its own).
However, i couldn't add edit boxes afer some time.
can anyone enlighten me? is there a restriction to the number of edit boxes that could be added?
is the way i do things correct? as in making edit boxes overlap each other so that they will be displayed correspondingly (in correct position) in the various tabs correctly. Hope You guys can help me out on this!!!
Thanks a lot!
|
|
|
|