|
What I have tried to test was how to use Function Template, then I copied a segment of codes from a book.
If I left float TFun(float, float) uncommented, the code works well; however, if I left int TFun(int, int) uncommented, the code did not work.
That is the problem I could not figure out.
#include <iostream>
template<class T> T TFun(T a, T b)
{
if (a > b)
return(a);
else
return(b);
}
float TFun(float, float);
void main(void)
{
std::cout << "The TFunimum of 100 and 200 is " <<
TFun(100, 200) << '\n';
std::cout << "The TFunimum of 5.4321 and 1.2345 is " <<
TFun(5.4321, 1.2345) << '\n';
}
DJ
|
|
|
|
|
As ilostmyid2 pointed out then TFun(5.4321, 1.2345) calls the template function with T = double , if you want to use the float TFun(float, float); function instead you should call it with TFun(5.4321f, 1.2345f); .
In other words, you are trying to match the wrong types together, and naturally the template function will be chosen as the primitive float function is never being picked by your code.
Hope that should clarify it.
--
Henrik Stuart (http://www.unprompted.com/hstuart/[^])
|
|
|
|
|
thanks for your quick reply.
DJ
|
|
|
|
|
hai all,
I am doing a project in MFC involving graphics.
I used pointerlist to add all the elements(line ,rectangle
or ellipse) drawn on the screen.
And,I redraw(refresh) all the elements in the pointer list,
while drawing a new element.
When more elements are added,the drawing gets very slow.
Is there any way to avoid this slowness without affecting the
previously drawn elements?
Plz help me.
With thanks,
arun chakaravarthy
|
|
|
|
|
check double buffering.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Hi
I want to use Regex class in my VC++ 7 application. I am familiar with VC++ 6. I want to use the .net framework in VC++ 7 application.
How do I include the header to use the Regex class ?
please anyone help me...
|
|
|
|
|
Just
using namespace System.Text.RegularExpressions;
and add reference System.Text.dll through project or
through code
#using <System.Text.dll>
and I suppose you have start up your project as .NET app in C++.
If you are not you will need to include
#using <mscorlib.dll>
#using <System.Text.dll>
and set your project setting to support clr.
and etc....
<B>Sonork 100.41263:Anthony_Yio
Life is about experiencing ... </B>
|
|
|
|
|
Hi all,
it is not a c++ question.
i am not in america and sent several emails to america universities before yesterday, but i did't get any feedback.
the email address looks like: xxx@yyy.edu
i suspect that i need to add .us if out of america as
xxx@yyy.edu.us
am i right? do u know which way is correct?
thx
includeh10
|
|
|
|
|
includeh10 wrote:
i am not in america and sent several emails to america universities before yesterday, but i did't get any feedback.
No news is good news, it means the mail did'nt bounced back, so the address should be ok ( have you checked on the web sites or other documentations ? ) Also, you might not be the only one trying to contact them by email, and it can take a while; I don't think most of them use "read-receipt"
I think most US universities use .edu, not .edu.us
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
hi all
i set up a right to left menu in my language for my application. but the items are not right aligned. it seems to be a bug in calculation of their widths:
http://home.morva.net/hamidi/menu-ye_kharab.gif
because when i use a fixed width font for menus in Appearance section of Desktop Properties, the problem gets fixed.
anyone has an idea or knows a workaround?
thanx
|
|
|
|
|
Hi
i am calling the open file dialog in my program
if (GetOpenFileName(&ofn)==TRUE)
hf = CreateFile(ofn.lpstrFile, GENERIC_READ,
0, (LPSECURITY_ATTRIBUTES) NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL);
however,when it displays it is placed in the top left of the screen
and not in the middle
can any1 help
thanks
si
|
|
|
|
|
Did you specify the HWND hwndOwner? in the ofn?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Papa wrote:
Did you specify the HWND hwndOwner? in the ofn?
i have declared
HWND hwnd;
ofn.hwndOwner = hwnd;
but get a runtime error, when it executes
|
|
|
|
|
you should specify the hwnd of your window
How are you creating your window?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
<small><b>Papa wrote:</b></small>
<i>you should specify the hwnd of your window</i>
eh ??? in english please
im delcaring it how it is in msdn
OPENFILENAME ofn; // common dialog box structure
char szFile[260]; // buffer for file name
HWND hwnd; // owner window
HANDLE hf; // file handle
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
// ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
//
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not
// use the contents of szFile to initialize itself.
//
ofn.lpstrTitle="Select CMIS Student Datafile";
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "Microsoft Access Files\0*.mdb\0All\0*.*\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
// Display the Open dialog box.
if (GetOpenFileName(&ofn)==TRUE)
hf = CreateFile(ofn.lpstrFile, GENERIC_READ,
0, (LPSECURITY_ATTRIBUTES) NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL);
|
|
|
|
|
Let me reformulate the question:
You are creating an application.
Are you using Direct Win32(CreateWindow) or MFC?
In either cases:
Win32 :
hwnd = CreateWindow(...
ofn.hwndOwner = hwnd;
MFC :
CWnd* pWnd = AfxGetMainWnd( );
if(pWnd)
ofn.hwndOwner = pWnd->m_hWnd;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
si_69 wrote:
HWND hwnd;
ofn.hwndOwner = hwnd;
but get a runtime error, when it executes
Because hwnd is not a valid window handle.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Where can I find a sample or documentation on ActiveX controls for use from MSAccess Forms.
I am trying to create an activex contol (SysListView32 derived) and trying figure what interfaces should I implement to bind it properly, provide a datasource for the items, etc.
Thanks in advance.
...Plug & Pray...
|
|
|
|
|
how to set the color of theme bar?in addition,how to simply set the button color?is there a simple way to know the practical display color that RGB represents?
|
|
|
|
|
Hi friends,
Currently i am developing one graphical application. The drawing tools like Rectangle, Ellipse, Freehand are kept in a toolbar. My intention is to display the toolbar whenever the user move the mouse to top zone of the client area and hide the toolbar whenever the user move the mouse away from the topzone. I constructed toolbar using Dialog Bar. But i don't know how to place the Dialog Bar in the view window.
Please help me regarding this.
Regards,
Prakash
A Journey of thousand miles must begin with a single step.
|
|
|
|
|
How can i get & set folder acess permission under NTFS file system?
Hello World
|
|
|
|
|
Try
http://www.sysinternals.com/ntw2k/source/accessenum.shtml
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Pls Explain what are network patches?
How do they occur?
Explain this with agood example.
|
|
|
|
|
Pls Explain what are network patches?
How do they occur?
Explain this with agood example.
AND 3 WORKER THREADS.PLS LET ME HOW TO EXCHANGE THE DATA BETWEEN THESE 3 WORKER THREADS.
FOR EX:THE FIRST THREAD WILL GIVE THE SECOND THREAD THE 2 NUMBERS AS ARGUEMENTS.the second thread should return the first thread the sum.
Pls help
|
|
|
|