DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   error C2664: 'setStartupDirectory' : cannot convert parameter (http://www.daniweb.com/forums/thread160833.html)

karang Dec 5th, 2008 3:03 am
error C2664: 'setStartupDirectory' : cannot convert parameter
 
Hi

I have a virtual function setStartupDirectory()

virtual bool setStartupDirectory(const SysString &sStartupDirectory) = 0;

When I am calling this function
setStartupDirectory((const SysString &)m_pApplicationFolderNarrow);
I am getting this error
Error 2 error C2664: 'setStartupDirectory' : cannot convert parameter 1 from 'const SysString' to 'const SysString &'

Am I missing something

cikara21 Dec 5th, 2008 3:24 am
Re: error C2664: 'setStartupDirectory' : cannot convert parameter
 
Here..
virtual void CSample1::Sample(SysString str)
(
  if(str.empty())
      return;
  //...
)
virtual void CSample2::Sample(SysString &str)
{
  str="what's up";
}
int main()
{
  SysString str1="check";
  SysString str2;
  CSample1 s1;
  CSample2 s2;
  s1.Sample(str1);
  s2.Sample(str2);
  return 0;
}

karang Dec 5th, 2008 3:56 am
Re: error C2664: 'setStartupDirectory' : cannot convert parameter
 
Hi

I have a function
bool setStartupDirectory(const SysString &sStartupDirectory)
{}

Now I want to give the prototype of the function how can I do that

sweeya Dec 5th, 2008 5:04 am
Re: error C2664: 'setStartupDirectory' : cannot convert parameter
 
You can directly make the call to the function as follows

setStartupDirectory(m_pApplicationFolderNarrow);


All times are GMT -4. The time now is 3:25 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC