|
Aniket Salunkhe wrote: It shows Linking error for the member functions of class. But when I remove template from Class the program runs well; even when I write all code (Class with template) in single "Program01.cpp" File then also it runs well.
Then what might be the problem in the above code?
Template classes should be defined and declared in .h files so that the compiler can generate code for these classes when an instantiation is required.
Because templates are compiled when required, this forces a restriction for multi-file projects: the implementation (definition) of a template class or function must be in the same file as its declaration. That means that we cannot separate the interface in a separate header file, and that we must include both interface and implementation in any file that uses the templates.
Remove definitions from .cpp file to .h file.
These days compilers do allow you to forward declare template types, but some compilers don't yet support them.
template < class T >
class AClass
{
int ATemplateFunction( T aObj );
};
template< class T >
int AClass< T >::ATemplateFunction( T aObj )
{
return 1;
}
|
|
|
|
|
Nibu babu thomas wrote: Template classes should be defined and declared in .h files
But I am creating Library ('Wind32 Static Library') using that code, so i can't write implementation of class in .h file.
So what should i do?
|
|
|
|
|
Aniket Salunkhe wrote: But I am creating Library ('Wind32 Static Library') using that code, so i can't write implementation of class in .h file.
So what should i do?
Look at what Microsoft has done for their template classes. They do have plenty of them. For eg: CArray , CPtrArray etc.
|
|
|
|
|
Where should I search for that?
|
|
|
|
|
Aniket Salunkhe wrote: Where should I search for that?
AfxTempl.h
|
|
|
|
|
I am doing a MFC project and want to change the tip on toolbar item.
I found some samples on Dialog to do that in codeproject, but none on MainFrame'stoolbar.
Can you help me?
|
|
|
|
|
|
Hi,
MY application consits of a button and a tree control.If i press the button, windows explorer files and folders will be displayed in the tree control with images.Now my problem is,if i press the button for the second time the images are not appearing in the tree control.How can i eliminate this problem.
Thanks in advance,
Radhika.
|
|
|
|
|
radhika28 wrote: MY application consits of a button and a tree control
What is the type of application?
radhika28 wrote: if i press the button for the second time the images are not appearing in the tree control.How can i eliminate this problem
Can you post some source code showing how are you going with the creation of the tree control etc....
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
void CApplication::OnButton1()
{
// TODO: Add your control notification handler code here
TCHAR szWorkDir[MAX_PATH];
if ( m_tree.m_hWnd )
{
if ( m_tree.SubclassDlgItem( IDC_TREE1, this ) )
{
m_tree.DisplayTree( NULL /*Display all*/, TRUE /* TRUE = Display Files*/ );
_getcwd( szWorkDir, 256 );
// set the Path to the current Work-Directory
m_tree.SetSelPath( szWorkDir );
}
}
}
|
|
|
|
|
radhika28 wrote:
TCHAR szWorkDir[MAX_PATH];
if ( m_tree.m_hWnd )
{
if ( m_tree.SubclassDlgItem( IDC_TREE1, this ) )
{
m_tree.DisplayTree( NULL /*Display all*/, TRUE /* TRUE = Display Files*/ );
_getcwd( szWorkDir, 256 );
// set the Path to the current Work-Directory
m_tree.SetSelPath( szWorkDir );
}
you have to check out for some flag !
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
i just want to read .pst file made by oulook ....
i have tried reading it by using ReadString function .its reading file but the strings r in some code format i just wanted to read 'em in some understandable manner...can anybody plsss give me some tips on how to use .pst file ???Is .pst file use any kind of data structure for storing our emails etc..........
|
|
|
|
|
pst files us a variant on the Jet database engine. You need to research the file structure and impliment the code to read it if you want to work with them. You really didn't expect it to be a bunch of plain text, did you ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
actually i want to recover my deleted files from the outlook.So i m not getting from where to start with??So if u can plssss guide me thru...it'll be of g8t help
|
|
|
|
|
LOL - I can tell you from personal experience ( outlook died for me earlier this week ) the web is full of people willing to sell you a program that will recover your PST. The sample versions all show you your mail but do not recover it, but I found ones as cheap as $50, which worked really quite well.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
thanku for ur suggestion
if u knw it or u can rather tell me how to read a pst file or in what file format does it contains its content or anythig related to a pst file
it'll be helpfull
thanxs
|
|
|
|
|
I thought I'd answered that question ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
if you want to read pst files see here[^]
|
|
|
|
|
I'm trying to move several CDialog-based classes to a common .lib file that will be statically linked.
I understand all the hoo-hah about resource handles when you're doing this with .dll's, but is there some magic dance I have to do to get dialogs to work when they're defined in a .lib?
My main program links to the lib just fine, but CDialog::DoModal() exits here:
if (lpDialogTemplate == NULL)
return -1;
What's more, when I open my executable file as resources in VS, the lib dialogs do not show up.
I know for a stone cold fact that this can be done, because I can statically link to external commercial libs like Stingray and get their dialogs to pop up. But I have studied that source code in vain for any clue as to why theirs works and mine doesn't.
Any suggestions?
|
|
|
|
|
how did u call the domodal of a dialog in the lib? I think this will be the issue of the resources handle.
overide the DoModal function in a derived class of the CDialog. And call
AFX_MANAGE_STATE(AfxGetStaticModuleState( )); and then call the base class' DoModal.
int MyDlg::DoModal()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
return CDialog::DoModal();
}
nave
|
|
|
|
|
Naveen R wrote: overide the DoModal function in a derived class of the CDialog. And call
AFX_MANAGE_STATE(AfxGetStaticModuleState( )); and then call the base class' DoModal.
That causes CDialog::DoModal to fail here:
HINSTANCE hInst = AfxGetResourceHandle();
because of an ASSERT:
_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()
{ ASSERT(afxCurrentResourceHandle != NULL);
And the CDialog resource is STILL not being linked into the executable. If I make a program that uses a statically-linked Stingray library and I open the executable as resources in VC, I can see the Stingray dialogs, whereas in my program, I cannot see the resources (and I even made sure that resource IDs were not duplicated in the lib and the main program).
I think this is the key issue here, the resources are simply not being linked into the executable for some reason.
|
|
|
|
|
I don't think you can put resources into a static library....
Steve S
Developer for hire
|
|
|
|
|
Thanks!
|
|
|
|
|
|
The idea I beleive was just that you could use stdafx as a way to get your includes type behaviour down. If you're writing code for non MS compilers as well, you shouldn't use stdafx, because you can reproduce the behaviour without having that nasty #ifdef ( nasty in the sense that you're making work for yourself, you can't rely on the stdafx, so why use it at all ? )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|