|
I now know that it is possible and here is how it can be done:
#include "stdafx.h"
#include <iostream>
using std::cout;
char szHello[] = "Hello ";
char szWorld[] = "World!";
template<char* str>
class X
{
public:
void print()
{
cout << str;
}
};
class Y : public X<szWorld>
{
public:
int i;
Y();
};
Y::Y () : X<szWorld>()
{
};
int main(int argc, char* argv[])
{
X<szHello> xObject;
xObject.print();
Y yObject;
yObject.print();
return 0;
} Thanks for all of your help.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I want to use the checkbox like this:
if(checkbox was clicked)
{}
else{}
how could I do ?
|
|
|
|
|
if (IsDlgButtonChecked (IDC_CHECKBOX)) {
} else {
} /ravi
Help put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Try this:
CButton * pButton = (CButton*)GetDlgItem(IDC_CHECK1);
if (pButton->GetCheck())
{
}
else
{
}
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Can anyone tell me how can I export template class from a DLL.
I have created a wrapper to wrap some STL containers (as STL can't export through DLL boundary), and wanna export the wrapper as accessor.
Say, I declared in "ListType.h"
<br />
#ifdef DLL_EXP<br />
#define MY_EXP __declspec(dllexport)<br />
#else<br />
#define MY_EXP __declspec(dllimport)<br />
#define<br />
<br />
template class MY_EXP CMapList<T><br />
{<br />
void insert(long key, T* pd)<br />
{<br />
....<br />
}<br />
bool next() { .... }<br />
T* get() { .... }<br />
<br />
....<br />
};<br />
<br />
class CMyClass1;<br />
class CMyClass2;<br />
<br />
CMapList<CMyClass1>;<br />
CMapList<CMyClass2>;<br />
I tried to use the wrapper class in the App project, but I experienced Access Violation with subsequence next() and get() calls.
How can I make sure the DLL project is exporting the class CMapList<cmyclass1> and CMapList<cmyclass2> ?
How can I avoid that the App project will use the declaration in the DLL, not generated CMapList<cmyclass1>, CMapList<cmyclass2> from the header file directly ?
Thanks for help ^^
|
|
|
|
|
Sorry, the code section before should be :
<br />
#ifdef DLL_EXP<br />
#define MY_EXP __declspec(dllexport)<br />
#else<br />
#define MY_EXP __declspec(dllimport)<br />
#define<br />
<br />
template class MY_EXP CMapList<T><br />
{<br />
void insert(long key, T* pd)<br />
{<br />
....<br />
}<br />
bool next() { .... }<br />
T* get() { .... }<br />
<br />
....<br />
};<br />
<br />
class CMyClass1;<br />
class CMyClass2;<br />
<br />
CMapList<CMyClass1><br />
CMapList<CMyClass2><br />
|
|
|
|
|
Can anyone tell me how can I export template class from a DLL.
Yes. Use Comeau C/C++ compiler. That is currently the only publicly available compiler that can make use of the export keyword.
The best you can do with MSVC is to export a specialization or provide a non-data-type-dependent implementation of something in/from the DLL and then create your class templates as thin wrappers around what the DLL exports.
|
|
|
|
|
But I have to tie to MSVC++ 6.0. I'm doing a wrapper to wrap the dependence of STL within the DLL. However, I don't know how to put the class template CMapList<cmyclass1> specification into the DLL. If I just put the template CMapList<cmyclass1> into the header file. Will it generate code to put into the DLL ? ( I don't think so )
|
|
|
|
|
However, I don't know how to put the class template CMapList specification into the DLL.
IIRC it looks something like
__declspec(dllexport) template<> class CMapList<your_type(s)>
That is intended to both create an explicit instantiation of the class template and export the instantiated template class.
But, isn't this in the compiler documentation? Like since Q168958 for VC5.
|
|
|
|
|
PC: CII733+20G+128M SDRAM..(because i'm a poor student,
I use win98. But when i setup win XP Professional, I found WIN XP's speed is so.... I want to know , as a programer fan, which OS you like it much? Point me!!!
|
|
|
|
|
I prefer to develop on 2000, but I expect I'll need to convert my aging spare PII-300 128M machine from 98 to XP in order to test my software.
/ravi
Help put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I am very happy with windows 2000, however I have not yet tried Windows XP.
I have an AMD K6 350 MHz running Windows 2000 and it is doing great.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
my god! that seems i need more memory for running win XP.
|
|
|
|
|
Any of the NT based operating systems, Win2000 being the best for development at the moment. I haven't developed on a 9x machine for years, they just crash too often and I could never tell if it was my bug or 9x being flaky.
I'm surprised at the amount of developers who still use 9x, even in large companies who can afford the Win2000 licences.
Michael
Errata 1: p. 154, section 'Defusing'. For 'red wire' read 'blue wire'.
|
|
|
|
|
LOL, I like your sig Michael.
Mark A
|
|
|
|
|
I'm surprised at the amount of developers who still use 9x, even in large companies who can afford the Win2000 licences.
Just because they can make Bill Gate$ richer doesn't mean that they want to.
|
|
|
|
|
Hi all,
I have a second user that logs into my computer that would like to have the same settings profile that I currently have on my machine. I am talking about the default IDE settings like the file directories, colors, macros and such, have all been reset with a new user account. I want to know if anybody knows how to transfer these settings from one user to another.
Thank you
kilowatt
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I figured out how to get the same macro file as the original setting, There is a macros tab on the custom ize dialog that allows you to select the file to enable for macros. I am still looking at how to import all of the other general settings though.
THanks
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Export and import the HKCU/Software/Microsoft/DevStudio (or Visual Studio) registry key.
|
|
|
|
|
Thanks!!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Sender: megawatt
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Oops that went anonymous. I thought that changing name did not effect post counts.
|
|
|
|
|
Rama Krishna wrote:
Oops that went anonymous. I thought that changing name did not effect post counts.
Serves you right for trying to pick on Kilo's poor nick
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Nish - Native CPian wrote:
Serves you right for trying to pick on Kilo's poor nick
I have a poor nickname, or did you mean "poor kilo's nick", or both could be true
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
kilowatt wrote:
I am still looking at how to import all of the other general settings though.
Most of the other settings are stored in the registry.
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.0
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|