|
Hello everyone,
I sometimes saw code with template<> and followed by a class definition, like,
<br />
template<> class {<br />
<br />
}<br />
I am wondering the practical usage of this trick. Why declar a template but leaving the content to nothing? If there is no type parameters, I do not think there is a need to put template<> statement.
thanks in advance,
George
|
|
|
|
|
Why do you put the () if the content is void?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Thanks Nelek,
I do not quite understand your points. What do you mean *() if the content is void*? I am not putting (), I am putting <>.
regards,
George
|
|
|
|
|
void main (void) == main ()
why to put the () if there is nothing inside?
You know the answer, dont u?
This is what I wanted to mean, just remake the question with <>
if you dont put the (), how does the compiler differenciate between variables and functions? if you dont put the <> how does the compiler differenciate between templates and other things (i.e. Typedefs?)
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hi Nelek,
My question is not about the syntax of template<>, but I can not see any practical usage of this trick. Could you list some practical usage of template<> please? I think if nothing is in template<>, we can remove the template<> declaration.
Please feel free to correct me if I am wrong. Thanks.
regards,
George
|
|
|
|
|
Ok, then I missunderstood your question, please report to cedrics answer
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
No problem Nelek, my question is not always clear.
regards,
George
|
|
|
|
|
You probably saw that in a template specialization case. But, normally, the name of the class should be followed by the specialized type.
Check here[^] for more information about template specialization.
|
|
|
|
|
Good link, Cedric!
My question is answered.
regards,
George
|
|
|
|
|
what is the different between the declaration of a variable in the header file and the declareation in the .cpp file?
For expamle, in my program I need an object "helpUIDCache" to contain a value before all functions run. and after the run of all functions I'll delete it in deconstructor.
in constructor:
static bool isCreatedCacheFile = false;
if(!isCreatedCacheFile)
{
helpUIDCache = new HelpUIDCache;
if (!helpUIDCache->createTestFile())
{
CPPUNIT_ASSERT_MESSAGE("Error in helpUIDCache.",false);
}
isCreatedCacheFile = true;
}
if deconstructor:
static int numOfFunctions = 0;
numOfFunctions ++;
if (numOfFunctions == 8)
{
wprintf(L"backup file name: %s\n",helpUIDCache->getBackupFileName() );
helpUIDCache->restoreCacheFile();
delete helpUIDCache;
}
If I declare "HelpUIDCache* helpUIDCache;" in the header file, in deconstructor the attribut of the object helpUIDCache is null, by wprintf I can not get the file name from it. But if I declare it in .cpp, the attribut contains its value in deconstructor. so what is the scope of the variable declaration in header and in .cpp file?
thanks in advance!
|
|
|
|
|
Are You getting Attributes of object in Constructor?
Check it first.
Thanks and Regards,
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
Yes. I can get the attributes in constructor.
|
|
|
|
|
Then declare your class variable in header file as public and initialize it in constructor and ckeck this variable in destructor is it null or not?
I think if itis not null then you can access its members, no problem with it.
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
I want to set the value of variable in constructor before the calling of all functions in class and delete it after runing of all functions in deconstructor, not before or after the calling of every function.
If there is only one function in my class, the value of variable is still available in deconstructor. If there are more than one functions in my class, the variable is null.
If I declare the variable in .cpp file. I can get its value after calling all of the functions in deconstructor.
|
|
|
|
|
Dear programmers,
I want to profile my MFC-C++ - Application in some way.
Can somebody give me any hint on available tools for this purpose?
Thanks a lot
|
|
|
|
|
|
hi all,
i'm developing an application using MFC dialog. I have to position the buttons and other controls depening on the Size of the screen.can anybody tell me how to do that, if possibel with sample code.
My dialog properties is set to MAXIMIZED
||SnAkeBed||
|
|
|
|
|
Do you want to use of WM_SIZE?
|
|
|
|
|
ya .. could you tell me how to use that properly
||SnAkeBed||
|
|
|
|
|
You should have a message handler for WM_SIZE message in your CDialog class. While resizing, the handler will be called with the dialog's width and height value. Deciside where to place your controls with respect to the size.
To position the controls you can use
SetWindowPos(...)
or
MoveWindow(...)
Do your Duty and Don't expect the Result
|
|
|
|
|
|
SnaKeBeD wrote: can anybody tell me how to do that, if possibel with sample code.
See if the Extras section of this article is of any help.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hai,
i am working in IOCP Socket programming..in this i want to craete multiple thread pools, which means 5 thread pools and each contains 100 threads...
like this...how to create this,,,
If u Knows,reply me...
Mani
Born to win...!
|
|
|
|
|
|
What does it have to do with a thread pool ?
|
|
|
|