Error C2664 Carray
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 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 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up issue returning CArray up vote 2 down vote favorite I am trying to return a CArray from a function and trying to call the function from another class short ListMaker::RetArray(CString szName, CArray &szarr_Names) { szarr_Names.Add(szName); return 0; } int main() { //.. CArray myArray; ListMaker LM; short nCode = LM.RetArray(L"Name", myArray); //.. } I am getting following errors: Error 1 error C2664: 'RetArray' : cannot convert parameter 2 from 'CArray' to 'CArray' Error 2 error C2511: 'short RetArray(CString,CArray &)' : overloaded member function not found in 'ListMaker' Please tell me the correct way to define and access the return value of the CArray. c++ windows visual-c++ mfc compiler-errors share|improve this question edited Feb 27 '15 at 16:20 Deduplicator 27.9k63265 asked Aug 5 '10 at 13:24 osum 3221319 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote accepted Erm, frist of all if RetArray is a member of ListMaker class and you call it from main(), you cannot call it like this: short nCode = RetArray(L"Name", myArray); If RetArray is a static member, use short nCode = ListMaker::RetArray(L"Name", myArray);. It it's non-static, use instance, short nCode = listMakerInstance.RetArray(L"Name", myArray);. Check your header file for RetArray declaration in ListMaker class. It might differ from the implementation in your cpp file, hence you get the C2511 error. share|improve this answer edited Apr 13 '12 at 6:54 answered Aug 5 '10 at 14:09 Aoi Karasu 2,98322451 yes, I have modified as you have suggested, but I am still getting the same error. Just tell me how to return and call CArray properly. –osum Aug 6 '10 at 5:07 add a com
I want topass this CArray to a function but I get this strange error:error C2664: cannot convert parameter 2from:'class CArray'to:'class CArray'This is the definition of the type I want to pass:CArray aCArray;The function prototype I am trying to pass this CArray to is:BOOL FunctionName(CString strMsg, CArray aDest, CListBox cDest);The two types are identical. I think i might need a copy constructor - isthis the case, if so can anyone provide an example copy constructor usingcustom http://stackoverflow.com/questions/3415063/issue-returning-carray types please.ThanksPT John Harrison 2003-07-25 20:09:01 UTC PermalinkRaw Message Post by Max AdamsAll,I have a CArray defined with my custom struct COMPONENT_DETAILS. I want toerror C2664: cannot convert parameter 2'class CArray''class CArray'CArray aCArray;BOOL FunctionName(CString strMsg, CArray aDest, CListBox cDest);The two types are identical. I think i might need a http://comp.os.ms-windows.programmer.win32.narkive.com/en4Z1IsT/cannot-convert-where-two-types-are-identical-error-c2664 copy constructor - isthis the case, if so can anyone provide an example copy constructor usingcustom types please.You might need one but you cannot have one. You cannot add a copyconstructor to a class you didn't write. CArray is a good example of theabysmal design that pervades the MFC. You would be well adviced to switch toa proper array class such as std::vector. Just look up vector in yourcompiler help.Alternatively if you really can't bear to drop the abominable CArray, thenyou are going to have to accept that you cannot copy it, no way. Pass yourarray by reference instead of by value.BOOL FunctionName(CString strMsg, const CArray & aDest, CListBox cDest);john Alex Blekhman 2003-07-27 12:12:24 UTC PermalinkRaw Message Post by John HarrisonPost by Max AdamsAll,I have a CArray defined with my custom struct COMPONENT_DETAILS.I wantPost by John HarrisontoPost by Max Adamserror C2664: cannot convert parameter 2'class CArray''class CArray'CArray aCArray;BOOL FunctionName(CString strMsg, CArray aDest, CListBox cDest);The two types are identical. I think
Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question View Unanswered Questions View All Questions... http://www.codeproject.com/Questions/234631/CArray-what-am-i-doing-wrong C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message http://www.sharkyforums.com/showthread.php?176366-help-with-error-for-CArray-in-C Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile error c2664 SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What error c2664 carray is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Ask a Question All Questions All Unanswered FAQ CArray, what am i doing wrong? Rate this: Please Sign up or sign in to vote. See more: C++ Declaration in header file: CArray ptArray; Source file void cDlgGrid::OnClick(NMHDR *pNotifyStruct, LRESULT* pResult) { LPNMITEMACTIVATE pNMIA = reinterpret_cast(pNotifyStruct); int row = pNMIA->iItem; int col = pNMIA->iSubItem; ptArray.SetSize(1,1); int SelectedCell[1][1]; SelectedCell[0][0] = row; SelectedCell[0][1] = col; ptArray.Add(SelectedCell); --> I am getting an error here error: C2664: 'CArray::Add' : cannot convert parameter 1 from 'int (*)[1][1]' to 'int [][1]' with [ TYPE=int [1][1], ARG_TYPE=int [1][1] ] Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast What should i do. Posted 1-Aug-11 5:31am amarasat1.4K Add a Solution 2 solutions Top Rated Most Recent Rate this: Please Sign up or sign in to vote. Solution 1 Accept Solution Reject Solution There are a number of things wrong here. To fix the compiler error you'd need to do this: ptArray.Add(*SelectedCell); or change the CArray declaration to: CArray ptArray; But that's the least of your
with error for CArray in C++??? If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 3 of 3 Thread: help with error for CArray in C++??? Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 01-31-2003,05:13 PM #1 Evan8 View Profile View Forum Posts Catfish Join Date Oct 2000 Posts 131 help with error for CArray in C++??? Hi all, i'm trying to use a CArray as an argument to a function, like so: void CPopulation::CalcMeanAndStdDev(CArray array, double &mean, double &stdDev) {...} so array is a CArray of doubles. Now when i actually call the function: CalcMeanAndStdDev(percentConnect, avg_percentConnected, stdDev_percentConnected); where percentConnected is another CArray of doubles, i get this error (which doesn't seem to make sense): c:\Documents and Settings\Evan Kuhn\Desktop\mechanisms\Population.cpp(266): error C2664: 'CPopulation::CalcMeanAndStdDev' : cannot convert parameter 1 from 'CArray' to 'CArray' with [ TYPE=double, ARG_TYPE=double ] and [ TYPE=double, ARG_TYPE=double ] Can anyone tell me what i'm doing wrong?? Any help is much appreciated. Thanks! -Evan Reply With Quote 02-01-2003,11:51 AM #2 Frostburn View Profile View Forum Posts Reef Shark Join Date Dec 2001 Location Henrietta, New York, USA Posts 264 http://msdn.microsoft.com/library/de...mfc_carray.asp Try this and see if it works: void CPopulation::CalcMeanAndStdDev(CArray array, double &mean, double &stdDev) {...} Reply With Quote 02-01-2003,12:20 PM #3 Evan8 View Profile View Forum Posts Catfish Join Date Oct 2000 Posts 131 no, unfortunately that didn't help. thanks anyway! -ev Reply With Quote Quick Navigation Programming, Coding, and Scripting Top Site Areas Settings Private Messages Subscriptions Who's Online Search Forums Forums Home Forums General Hardware/Software Technical Support Q/A General Hardware Operating Systems General Software, Applications, and Drivers Gadgets and Gizmos Reviews Programming, Coding, and Scripting Highly Technical PC Forum Hardware Specific CPU/Processors & Overclocking Reviews Cases and Cooling Reviews Completely Custom Motherboards Reviews Video Card