|
Hi,
int id;
const int Cinfo::get_id() const
{
return id;
}
I want to do these operations.
CInfo gh; //take obj of the class in some way.
int th = gh.get_id (how is it possibele to type cast)
int th =10;
if (th == gh.get_id) (how is it possible to compare)
COleDateTime CTableInfo::edit_date()
{
return edit_date;
}
COleDateTime ct;
CtableInfo in;
ct = in.edit_date(); //this is not happening and
//'=' : cannot convert from 'class COleDateTime (__thiscall
CToleranceTableInfo::*)(void)' to 'class COleDateTime *'
|
|
|
|
|
Cinfo::get_id() is a member function, so to call it you have to use the parameters at the end to denote the parameter list. If not you are getting the address of the function.
int th = gh.get_id(); kk_mfc wrote: COleDateTime CTableInfo::edit_date()
{
return edit_date;
}
Give your function and member variables different names. Right now the function is trying to return it's own address, cast to a COleDateTime pointer. It can not do that.
|
|
|
|
|
Thanks ...
the first solution worked out...
i am already using a different variable name...
COleDateTime CTableInfo::get_edit_date()
{
return m_edit_date;
}
COleDateTime dt;
CTableInfo cy;
dt = cy.get_edit_date();
error mess binary '=' : no operator defined which takes a right-hand operand of type 'class COleDateTime' (or there is no acceptable conversion)
and i am trying to compare the current date with previous date
if(dt == cy.get_edit_date())
if(dt > cy.get_edit_date())
error
binary '==' : no operator defined which takes a left-hand operand of type 'class COleDateTime' (or there is no acceptable conversion)
kk
|
|
|
|
|
What are the error numbers that the compiler gives you (C####)? Looking up those numbers in MSDN can be very helpful in figuring out the errors.
|
|
|
|
|
kk_mfc wrote:
COleDateTime dt;
CTableInfo cy;
dt = cy.get_edit_date();
error mess binary '=' : no operator defined which takes a right-hand operand of type 'class COleDateTime' (or there is no acceptable conversion)
The code you've shown is correct. The problem is related to other code that you've not shown. Change your CTableInfo class such that only necessary statements are present. In other words, remove the statements that have nothing to do with the problem.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You are not described complete code here.
This code with some spelling correction should work.
kk_mfc wrote: if (th == gh.get_id) (how is it possible to compare)
I think you want to use ,
if (th == gh.get_id ())
{
}
kk_mfc wrote: COleDateTime CTableInfo::edit_date()
{
return edit_date;
}
You have kept class member variable name and function name same.
kk_mfc wrote: ct = in.edit_date(); //this is not happening and
//'=' : cannot convert from 'class COleDateTime (__thiscall
CToleranceTableInfo::*)(void)' to 'class COleDateTime *'
If you corrected above mistake , this error should not come.
whats CToleranceTableInfo
? Thats why I said, you have not desribed your problem clearly.
|
|
|
|
|
Thanks ...
the first solution worked out...
i am already using a different variable name...
COleDateTime CTableInfo::get_edit_date()
{
return m_edit_date;
}
COleDateTime dt;
CTableInfo cy;
dt = cy.get_edit_date();
error mess binary '=' : no operator defined which takes a right-hand operand of type 'class COleDateTime' (or there is no acceptable conversion)
and i am trying to compare the current date with previous date
if(dt == cy.get_edit_date())
if(dt > cy.get_edit_date())
error
binary '==' : no operator defined which takes a left-hand operand of type 'class COleDateTime' (or there is no acceptable conversion)
kk
|
|
|
|
|
Thanks ...
the first solution worked out...
i am already using a different variable name...
COleDateTime CTableInfo::get_edit_date()
{
return m_edit_date;
}
COleDateTime dt;
CTableInfo cy;
dt = cy.get_edit_date();
error mess binary '=' : no operator defined which takes a right-hand operand of type 'class COleDateTime' (or there is no acceptable conversion)
and i am trying to compare the current date with previous date
if(dt == cy.get_edit_date())
if(dt > cy.get_edit_date())
error
binary '==' : no operator defined which takes a left-hand operand of type 'class COleDateTime' (or there is no acceptable conversion)
kk
|
|
|
|
|
prasad_som wrote: Are ***** placeholders for something ?
My first thought was a pointer to a pointer to a pointer...
My eyes just glazed over!
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
kk_mfc wrote: const int ********::get_id() const
{
return id;
}
I want to do these operations.
**** gh;
int th = gh.get_id (how is it possibele to type cast)
ACtually you are returning const int and your are taking it value in normal int..
either change th to const int th or remove const declaration from Get_id function
"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
|
|
|
|
|
Thanks ...
the first solution worked out...
i am already using a different variable name...
COleDateTime CTableInfo::get_edit_date()
{
return m_edit_date;
}
COleDateTime dt;
CTableInfo cy;
dt = cy.get_edit_date();
error mess binary '=' : no operator defined which takes a right-hand operand of type 'class COleDateTime' (or there is no acceptable conversion)
and i am trying to compare the current date with previous date
if(dt == cy.get_edit_date())
if(dt > cy.get_edit_date())
error
binary '==' : no operator defined which takes a left-hand operand of type 'class COleDateTime' (or there is no acceptable conversion)
kk
|
|
|
|
|
Hi,
I intend to integrate the functionality of two dlls into one by means of merging the code. I'm adopting the following steps.
1) Create a master framework for the merged entity say dll A.
2) Include all the files that are distinct for the two dlls(B & C) into the project created for dll A.
3) For all the files that are same in dll B and C, include a single file into the merged entity and into that file put all the functions that are distinct in the file under B and C.
I think this should suffice. Please correct if there is something to be done
The problem comes for functions that are same in the common file.
Say in dll B We have a function like
class B : function()
{
}
Say in dll C We have a function like
class C : function()
{
}
Here the two different functions need to be merged into a single function under a class name.
Now my question is how does the merged entity break into two workflows similar to the functional behavior in the previous separate dlls? What kind of conditional can be put for identifying the different behaviors?
Thanks
|
|
|
|
|
When you say they are two different functions then I feel there is no need to merge them as single function . Still , to do that just pass a boolean variable to function(bool flow) to determine which block of function() should be executed
redindian
|
|
|
|
|
how do i determine the boolean value
|
|
|
|
|
Hello everyone,
Could someone help me for how to open a RAS dial up using RasDial function knowing that
an adsl modem used, i wrote this code below
bool DialUp()
{
// Fill RASDIALPARAMS structure
RASDIALPARAMS rdParams;
rdParams.dwSize = sizeof(RASDIALPARAMS);
rdParams.szEntryName[0] = '\0';
lstrcpy(rdParams.szPhoneNumber, szPhoneNumberToDial);
rdParams.szCallbackNumber[0] = '\0';
lstrcpy( rdParams.szUserName, szUserName );
lstrcpy( rdParams.szPassword, szPassword );
rdParams.szDomain[0] = '\0';
HRASCONN hRasConn = NULL;
DWORD dwRet = RasDial( NULL, NULL, &rdParams, 0L, NULL, &hRasConn );
// Everything OK?
if (dwRet == 0)
return true;
// Error occurred - get error description and alert user
char szBuf[256];
if (RasGetErrorString( (UINT)dwRet, (LPSTR)szBuf, 256 ) != 0 )
wsprintf( (LPSTR)szBuf, "Undefined RAS Dial Error (%ld).", dwRet );
RasHangUp( hRasConn );
MessageBox( NULL, (LPSTR)szBuf, "Error", MB_OK | MB_ICONSTOP );
return false;
}
but when i excute the program i see the error message tell me that i have a bad modem configuration or modem port problem (my modem cofiguration is good)
any idea??
Thank you
---
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
John von Neumann
|
|
|
|
|
First thing to try is to properly initialize the RASDIALPARAMS structure before you use it.
bool DialUp()
{
RASDIALPARAMS rdParams = {0};
rdParams.dwSize = sizeof(RASDIALPARAMS);
...
|
|
|
|
|
It working fine when I tried this function to open the remote access service via telephone line and without adsl, But the function fail with adsl modem (USB cable), my question is:
does RAS dialing used for such connection ??(As you know most adsl connection use PPP protocol), beside that the DUN or WININET APIs are not important for me bcos i can set all connection configuration easily by filling RASDIALPARAMS structure ..
I welcome any idea
--
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
John von Neumann
|
|
|
|
|
Oh! damn!! the problem is self explained, i forgot that the RAS used for phone line and not for
adsl and particularly Virtual Private Network !
Thanks for help anyway
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
John von Neumann
|
|
|
|
|
Just wondering what the most compact way of writing this code is and how the c++ compiler implements the evalution order.
ps is a ptr to an unsigned char *
Under gcc-3.3.4 with -Wall there are no warnings with
*ps++=0xFF-*ps;
*ps++=0xFF-*ps;
*ps++=0xFF-*ps;
Under gcc-4 ps might be used unitialised.
The code below fixes the ordering problem But I was wondering if the LHS and RHS are evaluated in parallel in non deterministic order?
*ps=0xFF-*ps; ps++:
*ps=0xFF-*ps; ps++;
*ps=0xFF-*ps; ps++;
I would be interested in faster / more compact ways of doing this. Assembly?
I was also wondering without going to assembly if this is the fastest way of accessing the values in the register.
Thanks,
|
|
|
|
|
You're using ps in two parts of the expression, one of which has a side-effect. Don't do that.
Don't try to hand-optimize code unless you've profiled it and you know it's a bottleneck. You are not a better optimizer than the compiler writers. Making the code clear and readable is a much better goal.
|
|
|
|
|
Yes . The ps being on both sides has a side effect. I looked up the c++ standard but could not get any clarification on the order of the lvalue and rvalue computation in this case. Can you clarify?
It is most definately true that I am not a better optimiser than the compiler writers however apparently is is difficult for the compiler implementors to do very complex algebraic reductions as the following link shows. Experimenting with gcc -S and toggling -O2 yields some interesting results.
C++ Optimisation
Regards,
|
|
|
|
|
I tend to agree with Michael, probably not the place to worry about optimizing.
That said, i'd hate you to go away with nothing.
You could replace:
*ps = 0xff - *ps;
with:
*ps = ~*ps;
In assembly this will convert:
mov edx, 0ffh
sub edx, ecx
to:
not ecx
So, seeing as mov, sub and not are usually ~1 cycle you are probably only saving 1 cycle per use. Where you place the ps++ isn't likely to effect the resulting assembly, so make it clear rather than clever.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Thanks for the tip. I will take both your advice on board, however Optimisation does seem to be important in large scale image processing.
Regards,
|
|
|
|
|
i use WINAPI to built a DLL.There's a main dialog in it . when i want to open a new dialog according to a button on it, it failed . However i can if i use dynamic DLL to do it. How can I do? Thanx a lot.
|
|
|
|
|
hi
how i can create activex control include ather controls and activexs?
i user visual c++ 6
|
|
|
|