faq: type of CArray as function parameter create errors

Hi,

class CMyPoint
{
public:
	long x;
	long y;
	CArray<int,int&> m_intSegmentNo;
	CMyPoint();
	virtual ~CMyPoint();
	
	CMyPoint(const long &xx, const long &yy);
	CMyPoint(const CMyPoint &cmpt);
	CMyPoint(const CPoint &cpt);
	CMyPoint& operator = (const CMyPoint &assmypt);
	CMyPoint& operator = (const CPoint &asspt);
	bool operator == (const CMyPoint &rmypt);//const CMyPoint &lmypt,
	bool operator != (const CMyPoint &rmypt);//const CMyPoint &lmypt,

};
....
class CSegment
{
public:
	CList<CMyPoint,CMyPoint&> m_PointList;
	CSegment();
	CSegment(const CSegment& assignsegment);
	CSegment& operator = (const CSegment& asssignsegmet);
	virtual ~CSegment();
....
};
....
class CmaxborderView : public CView
{
public:
	CArray<CSegment, CSegment&> mysegmentarray,outsegmentarray;
		bool MaxBorder( CArray<CSegment, CSegment&> insegmentlist,
					CArray<CSegment, CSegment&> outsegmentlist);
....
};

All the tree class's members I defined as public, but when I used it,
void CmaxborderView::OnLButtonDown(UINT nFlags, CPoint point)
{
....
	MaxBorder(mysegmentarray,outsegmentarray);
....
}

the compile output as follows:
------ Build started: Project: maxborder, Configuration: Debug Win32 ------
Compiling...
maxborderView.cpp
d:\program files\microsoft visual studio
8\vc\atlmfc\include\afxtempl.h(272) : error C2248: 'CObject::CObject' :
cannot access private member declared in class 'CObject'
        d:\program files\microsoft visual studio
8\vc\atlmfc\include\afx.h(558) : see declaration of 'CObject::CObject'
        d:\program files\microsoft visual studio
8\vc\atlmfc\include\afx.h(529) : see declaration of 'CObject'
        This diagnostic occurred in the compiler generated function
'CArray<TYPE,ARG_TYPE>::CArray(const CArray<TYPE,ARG_TYPE> &)'
        with
        [
            TYPE=CSegment,
            ARG_TYPE=CSegment &
        ]
Generating Code...
Compiling...
Segment.cpp
Generating Code...
Compiling...
maxborder.cpp
Generating Code...
Build log was saved at "file://e:\border\Debug\BuildLog.htm"
maxborder - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Then I try to add friend class CmaxborderView to CSegment,
the problem still here. what is wrong?
Thanks.
0
fcvcnet
3/26/2007 6:05:38 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
552 Views

Similar Articles

[PageSpeed] 20

fcvcnet schrieb:

> class CmaxborderView : public CView
> {
> public:
> 	CArray<CSegment, CSegment&> mysegmentarray,outsegmentarray;
> 		bool MaxBorder( CArray<CSegment, CSegment&> insegmentlist,
> 					CArray<CSegment, CSegment&> outsegmentlist);
> ...
> };
> 
> maxborderView.cpp
> d:\program files\microsoft visual studio
> 8\vc\atlmfc\include\afxtempl.h(272) : error C2248: 'CObject::CObject' :
> cannot access private member declared in class 'CObject'

> 
> Then I try to add friend class CmaxborderView to CSegment,
> the problem still here. what is wrong?

You are passing a CArray object by value. If this workled, it would create full
copy of the array object with each function call. The CArray class does not
support that, by making the copy constructor private.

There are two possible solutions:
1. If you really need a copy of the array, use std::vector. As far as I know,
the stl containers do support the copy constructor. However, there are rare
cases where you really need that.

2. If you just need to access the array in MaxBorder, pass it a const reference:

bool MaxBorder( const CArray<CSegment, CSegment&>& insegmentlist,
                const CArray<CSegment, CSegment&>& outsegmentlist);

Norbert
0
nunterberg (207)
3/26/2007 6:52:50 AM
Norbert Unterberg �:
> fcvcnet schrieb:
> 
>> class CmaxborderView : public CView
>> {
>> public:
>> 	CArray<CSegment, CSegment&> mysegmentarray,outsegmentarray;
>> 		bool MaxBorder( CArray<CSegment, CSegment&> insegmentlist,
>> 					CArray<CSegment, CSegment&> outsegmentlist);
>> ...
>> };
>>
>> maxborderView.cpp
>> d:\program files\microsoft visual studio
>> 8\vc\atlmfc\include\afxtempl.h(272) : error C2248: 'CObject::CObject' :
>> cannot access private member declared in class 'CObject'
> 
>> Then I try to add friend class CmaxborderView to CSegment,
>> the problem still here. what is wrong?
> 
> You are passing a CArray object by value. If this workled, it would create full
> copy of the array object with each function call. The CArray class does not
> support that, by making the copy constructor private.
> 
> There are two possible solutions:
> 1. If you really need a copy of the array, use std::vector. As far as I know,
> the stl containers do support the copy constructor. However, there are rare
> cases where you really need that.
> 
> 2. If you just need to access the array in MaxBorder, pass it a const reference:
> 
> bool MaxBorder( const CArray<CSegment, CSegment&>& insegmentlist,
>                 const CArray<CSegment, CSegment&>& outsegmentlist);
> 
> Norbert
Great!
Thanks you Norbert Unterberg very much!
> The CArray class does not
> support that, by making the copy constructor private.

When I saw it, I remembered I have had red this on ebook. It says I just
 read and have not use it in practice.

> bool MaxBorder( const CArray<CSegment, CSegment&>& insegmentlist,
>                 const CArray<CSegment, CSegment&>& outsegmentlist);

This time
maxborder - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
0
fcvcnet
3/26/2007 8:03:09 AM
Reply:

Similar Artilces:

Problems with creating a newsletter
I chose the form "Newsletter - email". I have created a 3 page newsletter. Now, I have NO IDEA how to send it out as an email. I do not want to send it as an attachment. I cannot figure out which "save as" format or what I need to do so that i can email this newsletter. Is there a website that goes through how to do this? Am I correct when I say that it has to be html in order for me to send it as email? That is not one of the options. Any help you give me would be greatly appreciated. Thank you, Markis www.adreamforabetterworld.com ...

Business Portal Error-SQL server does not exist or access denied
Hi, We are running business portal 4.0 for one of our customer. It was running correctly, however, they have changed the SQL server port (previously it was set as default 1433). After that the business portal becomes very slow and while creating a new request (purchase requisition) if we open the item pop up; it is showing exception "SQL Server does not exist or access denied...." Can any body tell me how can I provide the new port number to business portal connection to the database. Thanks and Regards, Waliullah, Thanks for using the newsgroups. I have a...

What's happened to the findfirst function in Access 2010?
I have a working Access 2007 Application which is now failing miserably in 2010. It hinges on location the first available working document in a table runing the following VBA code: With Me.Recordset .FindFirst "([fld1] + [fld2]) = 0" If .NoMatch Then .FindLast "([fdl1] + [fld2]) <> 0" Exit Sub End If .... FURTHER PROCESSING ... What must I do to correct this? Go through a record by record search? End With In 2007, this works correctly, stopping at the appropriate record (approc. rec 1385 in the recordset...

Sort by Credit Card Type on EDC Detail Report
What do I have to do to get my EDC Detail Report to show different credit card types, like Visa, MC or Amex. Now under Tender Type, it just shows Credit card...well...I kinda knew that. How do I fix it? add tender types for each credit card type rather than just "credit card". then z out. all transactions after this change will reflect what you want in the reports. "tl" <tl@discussions.microsoft.com> wrote in message news:A54EEC95-208C-4962-A089-84B22A67632A@microsoft.com... > What do I have to do to get my EDC Detail Report to show different credit >...

crm 3.0 error 03-01-06
Hello, I'me getting this error while installing crm3.0 for SBS: "error writing to file microsoft.mshtml.dll verify that you have access to that directory" That file is in the C:\Program Files\Microsoft.NET\Primary Interop Assemblies directory. I (and 'everyone') has full access to that dir. What can I do about this?? kind regards, Thomas ...

VBA to creating autotext entries or quickparts in different catego
I have a VBA application that basically allows people to easily create autotext entiries, move them between machines and use them making comments on assignments. Currently it operates in EXACTLY the same way in Word 2003 and 2007 (using userforms) and I want to keep that as long as possible. You can see the application at http://emarking-assistant.baker-evans.com and either the screen image or the video demos will give you an idea of what I am doing Currently I store all the comments in a long list of autotext entries that is displayed in a field with the value of the entr...

Error in Outlook Today
Whenever I go to Outlook Today, I get a runtime error, line: 297 Error: Class Not Registered. Then I get the error two more times when I click 'Customize Outlook Today...' and the list 'Show Outlook Today In This Style' is empty, and the box under it has a broken image icon. What could be the cause of this? Sorry...forgot to say...I'm using Outlook 2003 Student and Teacher Edition on Windows XP. >-----Original Message----- >Whenever I go to Outlook Today, I get a runtime error, >line: 297 Error: Class Not Registered. Then I get the >error two more time...

Opening pub files created with older Publisher versions #2
I have just upgraded to Publisher 2003 from 2000 and am having trouble with pub files sent to me for our chuch newsletter which is using Publisher 97 The text is not wrapping around graphics boxes. Can I fix this? I really don't want to go back to Pub 200 Thank Richard this is caused by Publisher 97 not been printer independent. Even if you went back to Publisher 2000, unless you have the identical font versions and printer driver you would have issues with formatting. It sounds like the person sending you the file has a garbage HP inkjet printer. Get them to install the HP5P laser p...

Qrp Date functions
Where do I find the various functions to modify the Reports like cast(DatePart(Dd,[Transaction].Time) as nvarchar) and others and what they mean???? Barry Found the information at MSDN Transact-SQL Reference Barry "Barry L" <barryl@eryanjewelers.com> wrote in message news:usd3uP1CIHA.1188@TK2MSFTNGP04.phx.gbl... > Where do I find the various functions to modify the Reports > like cast(DatePart(Dd,[Transaction].Time) as nvarchar) and others > and what they mean???? > > Barry > ...

Re: 'Uknown Error 0x800CCC97'
I just heard back from the folks with whom I filed this bug. They say the bug is fixed in cppop 5.4 - request that your ISP upgrade to that. -- Jeff Stephenson Outlook Development This posting is provided "AS IS" with no warranties, and confers no rights "Jeff Stephenson [MSFT]" <stephenson@online.microsoft.com> wrote in message news:... > See the attached reply to another similar question. Your ISP's POP3 server > has a bug, and they should get a fixed version of the server. > > -- > Jeff Stephenson > Outlook Development > This posting...

stop error defeating me
Hi, XP Pro PC. When I start the computer I can start in safe mode but when I try to start in normal mode it loads to the log on screen. I type the username and password in then it starts to load but stops after a few moments with a blue screen. The error is Stop: c000021a (fatal system error) The windows subsystem system process terminated unexpectedly with a status of 0xc0000005 (0x7c9106c3 0x0055f36c). Begininning dump of physical memory. I have uninstalled AVG, also taken out the graphics card and uninstalled all the drivers for it. I have also changed the RAM. I have also d...

Error in database....
A user posted a batch in payables management. After posting, there was an error encountered. It displays that the table updating was interrupted, use batch recovery to continue the posting. But when I used the batch recovery, it was not successful to continue the update process. When I click the "More Details" button it displays, A save operation on table 'PM_Transaction_WORK' caused a sharing error. How can I resolve this issue? Thanks, John John, it is a db sharing violation. Have all users logout DELETE tempdb..DEX_LOCK DELETE tempd..DEX_SESSION DELETE dynami...

Some Excel formatting functions taking a long time to work #2
Excel 2000 SP3 When I use some formatting functions for the first time in a session, such as bold, increasing font size etc, it takes up to 30 seconds to work. Meantime Excel is locked up until it completes that formatting call. I suspect faulty DLL? Has anyone experienced this? How to fix (other than a complete re- install) ? Any advice appreciated. Piri On Nov 5, 8:39=A0am, Piri <wiremu.pare...@hotmail.com> wrote: > Excel 2000 SP3 > When I use some formatting functions for the first time in a > session, such as bold, increasing font size etc, it takes =A0up to 30 > secon...

parameter for text
In Access 2003. In a form I have a parameter to search for a word at a a time Like [Froms].[Form].txtWords]&"*" which works well. .. In order to enter more than two oarameter separated by commas in txtwords I have been tryin the Str function like this "Instr([txtWords])" "Instr[txtWords]" The query displays no records at all. Could you suggest me how to do it Many thanks I would suggest separating by space and using this -- Like "*" & [Froms].[Form].txtWords] &"*" Remember that when you type in 'bell...

Creating Text Box in Publisher 2007 Crashes the Application
Hello, we have a clean install of Publisher 2007 under Windows XP SP2, and when we try to create a text box in a document, (both an existing document and a blank document), publisher crashes. Office is fully patched. I ran Office Diagnostics from the help menu and no problems were found and the issue persists. Any thoughts on how to resolve the issue? Thanks, Syd See if selecting a different printer as default helps. How to view error signatures if an Office program experiences a serious error and quits http://support.microsoft.com/kb/289508/en-us -- Mary Sauer MSFT MVP http://of...

Creating a Macro to Delete Commas #2
I have an excel file that the size will varry. I need a macro that will check all the fields for a comma. If there is one I would like to get rid of it. Does anyone have any idea how to do this? I have no idea and I have been assigned this task. Help --- Message posted from http://www.ExcelForum.com/ No macro required. ctrl-H for find/replace. find , replace nothing (leave the replace field blank). You can of course record that within a macro if you wish. Drabbacs >-----Original Message----- >I have an excel file that the size will varry. I need a macro that will >check ...

Create Exchange mailbox from command line
I'm writing a script using dsadd and I was wondering if it's possible to create an exchange mailbox from the command line. Donovan Maybe not exactly what you want but it may help: http://www.joeware.net/win/free/tools/exchmbx.htm -- Neil Hobson Exchange MVP For Exchange news, links, and tips, check: http://www.msexchangeblog.com "Donovan Linton" <DonovanLinton@discussions.microsoft.com> wrote in message news:D9C839EF-883D-4E2E-8BE9-57782582F043@microsoft.com... > I'm writing a script using dsadd and I was wondering if it's possible to > create an ...

error 553
The following error occurs when sending email from my business domain. It does not occur when sending through my roadrunner account. The following recipient(s) could not be reached: on 10/22/2003 2:05 PM 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1) What does this mean and how can it be fixed? ...

creating a backup on 2002 for Money 98
I am helping a friend who has 98. I need to make a backup of info on my 2002 for him to use on 98. Any suggestions as to how to do this? M98 can't read any file written by M02 besides .QIF import. M02 can't write any file readable by M98 except for .QIF export. Sounds like QIF export/import is your only choice. I suspect you will find this doesn't do what you want. "Carlotte" <Carlotta41@discussions.microsoft.com> wrote in message news:015b01c3d2fa$bbf8fd60$a101280a@phx.gbl... > I am helping a friend who has 98. I need to make a > backup of info on...

80070005 error #2
I am getting this error when trying to view public folder property from system manager. My issue is same as what you can find out from http://forums.msexchange.org/ultimatebb.cgi? ubb=get_topic;f=19;t=000114 Anyone has a clue? ...

Using INDIRECT within functions
I learned a bit from JLathman in a previous post but tried to use the same methodology with this formula (also learned from this Group to get the last entered value in a column) without much luck. The original formula was this with 2009 sheet being static: =LOOKUP(2,1/('2009'!H3:H65536<>""),'2009'!H3:H65536) Trying to make it dynamic I tried the following without success: =LOOKUP(INDIRECT("2,1/(" & O1 & "!$H$3:$H$65536<>"")," & O1 & "!$H$3:$H$65536)")) Did I miss something or are...

Adding a Macro to a VLookup Function
In Excel 2000 -- I would like to create a summary spreadsheet (sheet2). For each time that "Name" appears in sheet 1, row *, take information from the same row, but columns 2 and 6 and bring it over to sheet 2 in the designated area. I know that you need to do a "VLookup" function and I got that to work. I know that you also need a "Loop" statement, so that it will continue to perform the Vlookup and bring over the information for each time that the name appears. I don't know how to write the formula so that the VLookup and the Loop are combined. Examp...

Date function quit working
Hi, I have an Access 2002 application that I have been running on Windows XP SP2 without issue. I just installed the application (running in Access Runtime) on a Windows Vista Home Premium machine. Now, anywhere I used the =Date() function, it fails and just shows #Name? I also have a subform on one of my forms that has now gone blank. It also uses the date function. I had this problem when I converted to Windows XP several years ago and updating the OWC10.dll to version 6619 fixed both issues. However, everything I have read says that reference file makes no difference to the Access...

total group & max function
I am using Access 2003 I created a Db for Machine Mtce. The table consists of 3 tables, (1) Basic Mach Infor (ie Mach#, Mach Name, Mfg etc) - (2) Operations Table - consists of different prev mtce (PM) that need to be completed at various time frames. Ex: "Mach 100" could have 3 different operations; Oper # 100A to change the oil due every 90 days, Oper # 100B to check the belts due every 180 days, Oper # 100C to grease the machine due every 365 days. The 3rd table is the "PM History" table which includes the history of all of the PM's completed with Work Order...

Function to determine Directory Size
I'd like to be able to determine the size of a directory or group of files. Does anyone know of an add-in that has a function whereby I can specify a path and get the size of directory of groups of files as the return value? Ex: =dirsize("C:\Documents and Settings\Bob\My Documents\School") =dirsize("C:\Documents and Settings\Bob\My Documents\School\*.doc") It would also be helpful if there were an option to include subdirectories. -- Thanks, Bob Chmara Argh.... Make that "get the size of a directory or group of files" Bob "Bob Chmara" fatfing...