|
also called "function polymorphism"
|
|
|
|
|
Polymorphism is generally used with reference to classes or objects, and it deals with method OVERRIDING, not overloading.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Arguments with default values must come at the end of the argument list. C++ does not provide a syntax for specifying missing arguments.
Another thing you might be seeing, since you are using numeric arguments, is that the compiler will automatically convert numeric constants to the correct type.
The best way to do this would be:
void Show(double d,int i = 1729)
{
printf("\n\t%d %lf",i,d);
}
main()
{
Show();
Show(12);
Show(5.6,45);
Show(23.9);
}
Software Zen: delete this;
|
|
|
|
|
You cannot pass just the second parameter. If you change the declaration so that the default parameters are the last arguments to your function, you can pass the first arguments and skip the default ones (if desired), but you cannot do it the way you are trying to.
Also, you cannot create the same function with the same arguments and different default parameters.
Aniket Salunkhe wrote: void Show(int i, double d = 3.14);
void Show(int i = 1729,double d);
void Show(int i, double d)
Declaring all 3 of those will give you a compiler error.
void Show(double d, int i = 1729);
Show(3.14);
Show(3.14, 2000);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Neither C nor C++ support "named parameters." See here for more.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: named parameters
One of the the (all too few) cool things about the Ada programming language. Named parameters made for more readable and self-documenting code.
Software Zen: delete this;
|
|
|
|
|
|
I've a weird problem making me crazy !!!
I've to read a sequence of dates from a text file and convert these dates into time_t.
I DON't want to take into account timezones and daylight savings, so the input date must be converted into the exact output date.
So, i've avoided mktime() to convert from tm (filled up with string dates from source) to time_t.
The next solution i've used was to convert a SYSTEMTIME to a time_t with these functions (based on similar functions, UnixTimeToSystemTime(), described in MSDN):
void FileTimeToUnixTime(LPFILETIME pft, time_t *t)
{
LONGLONG ll;
ll = pft->dwHighDateTime;
ll <<= 32;
ll |= pft->dwLowDateTime;
ll = ll - 116444736000000000;
*t = ll / 10000000;
}
void SystemTimeToUnixTime(LPSYSTEMTIME pst, time_t *t)
{
FILETIME ft;
SystemTimeToFileTime(pst, &ft);
FileTimeToUnixTime(&ft, t);
}
because I was sure that SystemTimeToFileTime() only converts to SYSTEMTIME format to FILETIME format without any other considerations like timezone or daylight saving.
In my PC these work well. When I've run the code in another PC, the resulting date is 1 hour back.
(it's very strange too, because that PC has the same date settings of mine).
I can't achive the result to obatin a time_t that reflect the same source date, without variations caused by currently timezone and daylight saving settings.
-- modified at 9:12 Thursday 3rd August, 2006
|
|
|
|
|
Nyarlatotep wrote: I've to read a sequence of dates from a text file...
What do these dates look like?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Input file is a CSV file. Dates are in dd/mm/yyyy format and I've to convert those dates into time_t without time zone o daylight saving affection ...
|
|
|
|
|
If you are reading the dates in as dd/mm/yyyy, then you can separate the three components like:
char dateToday[] = "04/08/2006";
char *pDay = strtok(dateToday, "/"),
*pMonth = strtok(NULL, "/"),
*pYear = strtok(NULL, "/"); Now you can convert those to numeric values using atoi() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
My problem is not to parse the input string date.
I parse the input date and input time and put each value into a tm struct (day, month, year, hour, minutes, seconds) and I'have used mktime() function to convert from the tm struct to time_t value.
BUT
mktime() takes into account time zone and daylight saving so, for example, if input date into the tm struct is 01/06/2006 15:00:00 (first June), the time_t date obtained from mktime() is 01/06/2006 17:00:00 (I am in GMT +1 and day light saving is in effect adding an extra hour).
Instead I want to convert the parsed date into time_t without take into account time zones and day light saving, obtaining the the same date as the input, in every time zone the program runs.
To avoid this 'problem' I've tried to use a function (see inital post) that use SystemTimeToFileTime internally, because I thought that SystemTimeToFileTime only converts from SYSTEMTIME struct to FILETIME struct without taking into account time zones and day light saving. But I was wrong, I suppose.
-- modified at 10:23 Friday 4th August, 2006
|
|
|
|
|
Nyarlatotep wrote: My problem is not to parse the input string date.
My bad. I just assumed you had the math worked out, but was having difficulty with the parsing.
Nyarlatotep wrote: ...mktime() takes into account time zone and daylight saving so...
So what is the value of tm_isdst prior to calling mktime() ?
Nyarlatotep wrote: ...the time_t date obtained from mktime() is 01/06/2006 17:00:00
What are you using to convert the time_t value to a string?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I've set tm_isdst to 0.
However to convert the string into time_t I've used these functions (insted of mktime):
void FileTimeToUnixTime(LPFILETIME pft, time_t *t)
{
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = pft->dwHighDateTime;
ll <<= 32;
ll |= pft->dwLowDateTime;
ll = ll - 116444736000000000;
*t = ll / 10000000;
}
void SystemTimeToUnixTime(LPSYSTEMTIME pst, time_t *t)
{
FILETIME ft;
SystemTimeToFileTime(pst, &ft);
FileTimeToUnixTime(&ft, t);
}
the datetime string is parsed and a SYSTEMTIME struct is filled. Then SystemTimeToUnixTime() is used to convert from SYSTEMTIME to time_t.
---------------------------------------------------
To revert time_t to a string I've used these functions :
void UnixTimeToFileTime(time_t t, LPFILETIME pft)
{
// Note that LONGLONG is a 64-bit value
LONGLONG ll;
ll = Int32x32To64(t, 10000000) + 116444736000000000;
pft->dwLowDateTime = (DWORD)ll;
pft->dwHighDateTime = ll >> 32;
}
void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
{
FILETIME ft;
UnixTimeToFileTime(t, &ft);
FileTimeToSystemTime(&ft, pst);
}
time_t is converted to a SYSTEMTIME by UnixTimeToSystemTime(). Then I've build a datetime string using SYSTEMTIME members.
These functions use internally FileTimeToSystemTime() and SystemTimeToFileTime() and no other OS functions.
I've thought that these two functions only convert SYSTEMTIME to FILETIME and vice versa without taking into account time zone and day light saving ...
|
|
|
|
|
I'm not sure what effect all of those other functions have on the date value, but I tried the following and got the correct output both times regardless of the value of tm_isdst :
struct tm now;
now.tm_sec = 0;
now.tm_min = 0;
now.tm_hour = 15;
now.tm_mday = 1;
now.tm_mon = 5;
now.tm_year = 106;
now.tm_wday = 5;
now.tm_isdst = 1;
printf("%s", asctime(&now));
time_t t2 = mktime(&now);
printf("%s", ctime(&t2)); I guess I'm just not understanding your problem well enough.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
How can I modify the Untitled "title" that apears in my SDI aplication? I modified AFX_IDS_APP_TITLE "My aplication". But on the right of it it apears Untitled like this:
Untitled= My aplication.
So???
|
|
|
|
|
What exactly is it that you are wanting? If you are not wanting "Untitled" in the caption, see here.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Serch for IDR_MAINFRAME in string table resource and insert the desired string between first and second '\n', like for example:
MyApp\nMY COOL NEW DOCUMENT\nMyApp\n\n\nMyApp.Document\nMyApp Document
-- modified at 9:01 Thursday 3rd August, 2006
PS. Tanar, tanar, dar de ce asa de nelinistit?
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
... and moreover, if you want to write in the caption anything your muscles want, override CFrameWnd::OnUpdateFrameTitle, like for example:
class CMainFrame : public CFrameWnd
{
public:
virtual void OnUpdateFrameTitle(BOOL bAddToTitle);
};
void CMainFrame::OnUpdateFrameTitle(BOOL bAddToTitle)
{
SetWindowText(_T("Asta-i pohta ce-am pohtit!"));
}
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
|
Mai Flaviu, vrei sa te calmezi putzin?
Please, explain what's really your problem.
You cannot find in a list an item which was not inserted?
Ovidiu Cucu
Microsoft MVP - Visual C++
|
|
|
|
|
Whats your prblem,exactly?
why you write a new thread for this object repeated?
|
|
|
|
|
What in the world are you asking here? Are you wanting to know how to populate a list control from a database? If so, there's an example of that here. If it's something else, please explain in more detail.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
It is not clear if your items -- loaded from FoxPro database -- are successfully inserted into your list control. If they appear in the list control, but FindItem apparently cannot find them, maybe they contain some additional spaces returned from FoxPro?
Maybe you should try something like this:
m_list.InsertItem(..., CString(text_from_database).Trim());
m_list.SetItemText(..., 1, CString(text_from_database).Trim());
I hope executing your program in step-by-step manner and providing reasonable details can help to solve the problem quickly.
|
|
|
|