CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2021
    Posts
    51

    How to fix Compile Wrong datatype on vs2019?

    Hi,
    I have created 4 methods as follows:
    Code:
              void Range::WriteValue(CStringW value)
    	  {
    		
    	  }
    	  void Range::WriteValue(int value)
    	  {
    		
    	  }
    	  void Range::WriteValue(double value)
    	  {
    		
    	  }
    	  void Range::WriteValue(bool value)
    	  {
    		
    	  }
    then, I called it by this code :
    Code:
    Range(L"A1").WriteValue(L"hello world");
    but it seem not compiled param L"hello world" as CString but bool,
    Is there a way for the compiler to understand I'm using a CString without having to specifically like this:
    Code:
    Range(L"A1").WriteValue(CString(L"hello world"));
    Thanks you!
    Last edited by Dang.D.Khanh; July 9th, 2021 at 01:15 AM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: How to fix Compile Wrong datatype on vs2019?

    Why don't you want to add the overloaded:
    Code:
          void Range::WriteValue(LPCWSTR value)
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 2021
    Posts
    51

    Re: How to fix Compile Wrong datatype on vs2019?

    Hi Sir,
    Now it worked.
    I'm quite unfamiliar with LPC*** type, because I usually just use CString and const wchar_t* .
    Are these two datatypes similar?

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: How to fix Compile Wrong datatype on vs2019?

    Victor Nijegorodov

  5. #5
    Join Date
    Jun 2021
    Posts
    51

    Re: How to fix Compile Wrong datatype on vs2019?

    Thanks Sir ,
    I will definitely use them more.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured