Home > error c2662 > error c2662 msdn

Error C2662 Msdn

Contents

XXX to XXX Visual Studio Languages , Windows Desktop Development > C++ Standards, Extensions, and Interop Question 0 Sign in to vote Please look at my

Error C2662 Conversion Loses Qualifiers

code: #pragma once class CBox { protected: double m_length; double m_width; double m_high; error c2662 cannot convert 'this' pointer from public: CBox(void); virtual ~CBox(void); CBox(double, double, double); virtual double volumn(); void showVolumn(); void showSize(); bool operator < (const CBox&) const; c++ error c2664 }; #include "StdAfx.h" #include "Box.h" #include using std::cout; using std::endl; CBox::CBox(void) { } CBox::~CBox(void) { //cout << "CBox destructor invoked~~" << endl; } CBox::CBox(double a, double b, double c) : m_length(a),

C2440

m_width(b), m_high(c){} double CBox::volumn() { return this->m_high * this->m_length * this->m_width; } void CBox::showVolumn() { cout << "this volumn of this box is : " << volumn() << endl; } void CBox::showSize() { cout << "m_lenght : " << m_length << endl; cout << "m_widht : " << m_width << endl; cout << "m_high : " << m_high << endl; } bool CBox::operator <(const

C++ Const Function

CBox & cbox) const { double total1 = m_length + m_width + m_high; double total2 = cbox.m_length + cbox.m_width + cbox.m_high; if (total1 < total2) { return true; } return false; } void test_15() { using namespace std; map hashMap; pair pair1(CBox(1, 3, 5), "box1"); typedef pair::iterator, bool> CBoxPair; CBoxPair cboxPair = hashMap.insert(pair1); testInserted(cboxPair.second); cout << "out put first pair's size : " << endl; cboxPair.first->first.showSize(); pair pair2(CBox(1, 2, 3), "box2"); cboxPair = hashMap.insert(pair2); testInserted(cboxPair.second); cout << "out put second pair's size : " << endl; //cboxPair.first->first.showSize(); } when I build my code, I got the following error: 1>Review.cpp 1>c:\documents and settings\zhanzhex\my documents\visual studio 2008\projects\review\review\review.cpp(329) : error C2662: “CBox::showSize”: cannot convert “this”pointer from “const CBox” to “CBox &” why I got this problem, how can I fix it? Tuesday, June 26, 2012 9:20 AM Reply | Quote Answers 1 Sign in to vote >how can I fix it? One possible solution: class CBox { protected: double m_length; double m_width; double m_high; public: CBox(void); virtual ~CBox(void); CBox(double, double, double); virtual double volumn(); void showVolumn(); // void showSize(); void showSize() const;

resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. C/C++ Building Reference C/C++ Build Errors Compiler Errors C2600 Through C2699 Compiler Errors C2600 Through https://social.msdn.microsoft.com/Forums/vstudio/en-US/ca0de267-afde-43c2-b0b0-c62edc783307/compiling-error-c2662-cannot-covert-this-pointer-from-xxx-to-xxx?forum=vclanguage C2699 Compiler Error C2664 Compiler Error C2664 Compiler Error C2664 Compiler Error C2600 Compiler Error C2601 Compiler Error C2602 Compiler Error C2603 Compiler Error C2605 Compiler Error C2611 Compiler Error C2612 Compiler Error C2613 Compiler Error C2614 Compiler Error C2616 Compiler Error C2617 Compiler Error C2619 Compiler Error C2624 https://msdn.microsoft.com/en-us/library/s5b150wd.aspx Compiler Error C2626 Compiler Error C2627 Compiler Error C2628 Compiler Error C2630 Compiler Error C2632 Compiler Error C2633 Compiler Error C2634 Compiler Error C2635 Compiler Error C2636 Compiler Error C2637 Compiler Error C2638 Compiler Error C2640 Compiler Error C2645 Compiler Error C2646 Compiler Error C2647 Compiler Error C2648 Compiler Error C2649 Compiler Error C2650 Compiler Error C2651 Compiler Error C2652 Compiler Error C2653 Compiler Error C2654 Compiler Error C2655 Compiler Error C2656 Compiler Error C2657 Compiler Error C2658 Compiler Error C2659 Compiler Error C2660 Compiler Error C2661 Compiler Error C2662 Compiler Error C2663 Compiler Error C2664 Compiler Error C2665 Compiler Error C2666 Compiler Error C2667 Compiler Error C2668 Compiler Error C2669 Compiler Error C2670 Compiler Error C2671 Compiler Error C2673 Compiler Error C2674 Compiler Error C2675 Compiler Error C2676 Compiler Error C2677 Compiler Error C2678 Compiler Error C2679 Compiler Error C2680 Compiler Error C2681 Compiler Er

resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re https://msdn.microsoft.com/en-us/library/dyafzty4.aspx sorry. The content you requested has been removed. You’ll be auto redirected in http://www.errorbase.net/1845/error-c2662-function-cannot-convert-this-pointer-from-type1-to-type2 1 second. C/C++ Building Reference C/C++ Build Errors Compiler Errors C2600 Through C2699 Compiler Errors C2600 Through C2699 Compiler Error C2666 Compiler Error C2666 Compiler Error C2666 Compiler Error C2600 Compiler Error C2601 Compiler Error C2602 Compiler Error C2603 Compiler Error C2605 Compiler Error C2611 Compiler Error C2612 Compiler Error C2613 Compiler Error C2614 error c2662 Compiler Error C2616 Compiler Error C2617 Compiler Error C2619 Compiler Error C2624 Compiler Error C2626 Compiler Error C2627 Compiler Error C2628 Compiler Error C2630 Compiler Error C2632 Compiler Error C2633 Compiler Error C2634 Compiler Error C2635 Compiler Error C2636 Compiler Error C2637 Compiler Error C2638 Compiler Error C2640 Compiler Error C2645 Compiler Error C2646 Compiler Error C2647 Compiler Error C2648 Compiler Error C2649 Compiler Error C2650 Compiler Error error c2662 msdn C2651 Compiler Error C2652 Compiler Error C2653 Compiler Error C2654 Compiler Error C2655 Compiler Error C2656 Compiler Error C2657 Compiler Error C2658 Compiler Error C2659 Compiler Error C2660 Compiler Error C2661 Compiler Error C2662 Compiler Error C2663 Compiler Error C2664 Compiler Error C2665 Compiler Error C2666 Compiler Error C2667 Compiler Error C2668 Compiler Error C2669 Compiler Error C2670 Compiler Error C2671 Compiler Error C2673 Compiler Error C2674 Compiler Error C2675 Compiler Error C2676 Compiler Error C2677 Compiler Error C2678 Compiler Error C2679 Compiler Error C2680 Compiler Error C2681 Compiler Error C2682 Compiler Error C2683 Compiler Error C2687 Compiler Error C2688 Compiler Error C2689 Compiler Error C2690 Compiler Error C2691 Compiler Error C2692 Compiler Error C2693 Compiler Error C2694 Compiler Error C2695 Compiler Error C2696 Compiler Error C2698 TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Compiler Error C2666 Visual Studio 2015 Other Versions Visual Studio 2013 Visual Studio 2012 Visual Studio 2010 Visual Studio 2008 Visual Studio 2005 Visual Studio .NET 2003  'identifier' : number overloads have similar conversionsAn overloaded function or operator is ambiguous. Formal parameter lists may be to

error messages. Tweet Most popular tags programming languages visual c++ compile time error messages programming-languages visual-c compile-time-error-messages java mysql dbms runtime-error-messages Photoshop oracle netbeans nudge photoshop mosek rasterize subversion php sql vector data svn facebook tomcat latex apache visual sap phpmyadmin runtime error messages c type layer windows eclipse-svn-subversion-java photos pool paypal sqlserver driver commit rsa 2010 adobe-premiere-pro c# jquery javascript firebug lyx asp memory-leaks Error C2662: (function) : cannot convert 'this' pointer from (type1) to (type2) 0 votes The compiler could not convert the this pointer from type1to type2. This error can be caused by invoking a non-const member function on a const object. compile time error messages programming languages visual c++ requested 5 years ago by errorbase (170,010 points) 3 Solutions 0 votes This article is a derivative work based on http://msdn.microsoft.com/en-us/library/2s2d2tez.aspx" title="http://msdn.microsoft.com/en-us/library/2s2d2tez.aspx" target="_blank">Compiler Error C2662 which is provided by http://msdn.microsoft.com/en-us/library/60k1461a.aspx" title="http://msdn.microsoft.com/en-us/library/60k1461a.aspx" target="_blank">MSDN Community Content - Visual C++. solved 5 years ago by errorbase (170,010 points) 0 votes Include other causes to the article that may trigger this error. Also give some code examples. solved 5 years ago by errorbase (170,010 points) 0 votes Possible resolutions: Remove the const from the object declaration. Add const to the member function. solved 5 years ago by errorbase (170,010 points) Related errors 0 votes 3 solutions Error C2664: (function) : cannot convert parameter number from (type1) to (type2) requested 5 years ago by errorbase (170,010 points) compile time error messages programming languages visual c++ 0 votes 3 solutions Error C2682: cannot use casting operator to convert from (type1) to (type2) requested 5 years ago by errorbase (170,010 points) compile time error messages programming languages visual c++ 0 votes 3 solutions Error C2440: (conversion) : cannot convert from (type1) to (type2) requested 5 years ago by errorbase (170,010 points) compile time error messages programming languages visual c++ 0 votes 2 solutions Error C3398: (operator) : cannot convert from (function signature) to (function pointer). Source expression must be a function symbol requested 5 years ago by errorbase (170,010 points) compile time error messages programming languages visual c++ 0 v

 

Related content

c2662 error

C Error table id toc tbody tr td div id toctitle Contents div ul li a href Error C a li li a href Error C a li li a href Error C a li li a href Error C Conversion Loses Qualifiers a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of relatedl this site About Us Learn more about Stack Overflow the p h id Error C p company Business Learn more about hiring developers

error 1 error c2662

Error Error C table id toc tbody tr td div id toctitle Contents div ul li a href Error C Cannot Convert This Pointer From Const To Conversion Loses Qualifiers a li li a href Const Method a li ul td tr tbody table p resources Windows Server resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community relatedl Magazine Forums Blogs Channel Documentation APIs and reference error c conversion loses qualifiers Dev centers Retired content Samples We re sorry The content you requested has error c cannot convert this pointer from

error c2662 volatile

Error C Volatile table id toc tbody tr td div id toctitle Contents div ul li a href Error C Cannot Convert this Pointer From a li li a href C Error C a li li a href C Cannot Convert This Pointer From Const a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies relatedl of this site About Us Learn more about Stack Overflow error c conversion loses qualifiers the company Business Learn more about hiring

error c2662 cannot convert this

Error C Cannot Convert This table id toc tbody tr td div id toctitle Contents div ul li a href Error C Conversion Loses Qualifiers a li li a href Error C Cannot Convert This Pointer From Const To Conversion Loses Qualifiers a li li a href Const Function a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss relatedl the workings and policies of this site About Us Learn error c cannot convert this pointer from const to more about Stack

error c2662

Error C table id toc tbody tr td div id toctitle Contents div ul li a href Error C a li li a href Error C a li li a href Error C a li ul td tr tbody table p resources Windows Server resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups relatedl TechRewards Events Community Magazine Forums Blogs Channel Documentation error c conversion loses qualifiers APIs and reference Dev centers Retired content Samples We re sorry The error c cannot convert this pointer from content you requested has been removed You ll

error c2662 this const

Error C This Const table id toc tbody tr td div id toctitle Contents div ul li a href Error C Conversion Loses Qualifiers a li li a href Const Method a li li a href Const cast Example a li li a href Const Function a li ul td tr tbody table p resources Windows Server resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards relatedl Events Community Magazine Forums Blogs Channel Documentation APIs c error c cannot convert this pointer from const to and reference Dev centers Retired content Samples We

error c2662 visual studio

Error C Visual Studio table id toc tbody tr td div id toctitle Contents div ul li a href Error C Conversion Loses Qualifiers a li li a href C Cannot Convert This Pointer From Const a li li a href Cannot Convert This Pointer From Const To a li li a href C Const Function a li ul td tr tbody table p resources Windows Server resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups relatedl TechRewards Events Community Magazine Forums Blogs Channel p h id Error C Conversion Loses Qualifiers p Documentation

error c2662 cannot

Error C Cannot table id toc tbody tr td div id toctitle Contents div ul li a href Error C Cannot Convert this Pointer From a li li a href Cannot Convert This Pointer From Const To a li li a href Const cast Example a li li a href Const Correctness a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies relatedl of this site About Us Learn more about Stack Overflow the p h id Error

error c2662 iterator

Error C Iterator p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss relatedl the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of million programmers just like you helping each other Join them it only takes a minute Sign up Visual Studio error C - calling const methods

error c2662 copy constructor

Error C Copy Constructor table id toc tbody tr td div id toctitle Contents div ul li a href Error C Cannot Convert this Pointer From a li ul td tr tbody table p Programming Boards C Programming Copy constructor error 'this' pointer conversion Getting started with C or C C relatedl Tutorial C Tutorial C and C FAQ error c conversion loses qualifiers Get a compiler Fixes for common problems Thread Copy constructor error 'this' p h id Error C Cannot Convert this Pointer From p pointer conversion Thread Tools Show Printable Version Email this Page hellip Subscribe to

error c2662 const

Error C Const table id toc tbody tr td div id toctitle Contents div ul li a href Cannot Convert This Pointer From Const To a li li a href Const cast Example a li li a href Const Function a li ul td tr tbody table p here for a quick overview of the site relatedl Help Center Detailed answers to any questions you c c might have Meta Discuss the workings and policies of this site error c conversion loses qualifiers About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or error

error c2662 cannot convert

Error C Cannot Convert table id toc tbody tr td div id toctitle Contents div ul li a href Visual Studio Error C a li li a href C Error C a li li a href Const Method a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers relatedl to any questions you might have Meta Discuss the error c cannot convert this pointer from workings and policies of this site About Us Learn more about p h id Visual Studio Error C p Stack Overflow the company Business Learn