how to declare an alias for a 2 dimensional array element?

Hi,

I have an array below (in a very old piece of code):
   float (*fList)[6];
   fList = new float[50][6];
   ....

My question is how to declare an alias for fList[10]:
   float &(p[6]) = fList[10];
   float &p[6] = fList[10];
   or ????

   // The following is what I want to use p for.
   for (int i=0; i<6; i++)
   {
     p[i] /= 5.;
   }

Please help.  I know we should always avoid multi-dimensional array. 
Unfortunately, this is a very old piece of code.  Thanks.

Tony

0
tony6018 (73)
1/27/2004 11:13:58 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
655 Views

Similar Articles

[PageSpeed] 29

May Young wrote:

>Hi,
>
>I have an array below (in a very old piece of code):
>   float (*fList)[6];
>   fList = new float[50][6];
>   ....
>
>My question is how to declare an alias for fList[10]:
>   float &(p[6]) = fList[10];
>   float &p[6] = fList[10];
>   or ????
>
>   // The following is what I want to use p for.
>   for (int i=0; i<6; i++)
>   {
>     p[i] /= 5.;
>   }

Try:

 // fList[10] is a float[6] array, so it decays into float* when
 // converted to a pointer.
 float* p = fList[10];

If you need to preserve the "arrayness" of fList[10], try:

 // p is a reference to a float[6] array; the array to pointer
 // conversion does not occur here.
 float (&p)[6] = fList[10];

-- 
Doug Harrison
Microsoft MVP - Visual C++
0
dsh (2498)
1/28/2004 1:57:39 AM
Reply:

Similar Artilces:

Public Folder Auto-reply #2
Hi Is there any way that I can enable an auto-reply for emails that are going to a Public Folder that is mail enabled. The emails will not only becoming from inside th company but externally as well. Thanx for the help Sulaiman yes, you can...on the Administration tab, click Folder Assistant...but be very cautious with this...it's very easy to get into a "mail loop" condition that could conceivably crash the store... -- Susan Conkey [MVP] "Sulaiman" <Sulaiman@discussions.microsoft.com> wrote in message news:9E3D127F-2CBE-40D3-9AC3-333F3D25B465@microsoft....

DoModel () declaration
Hi freinds. i am new in MFC programming. I made a project and then add new dialog class.Then i wanted to connect it with classview.Becoz i wrote a code in classview.But it shows always this errors. error C2039: 'DoModel' : is not a member of 'AddBookDlg' error C2039: 'm_BookTitle' : is not a member of 'AddBookDlg'. my code is : void CBookInformationView::OnAdd() { AddBookDlg dlg; if (dlg.DoModel()==IDOK) { CBookInformationSet book; ASSERT(! book.Open()); try { book.Open(); ASSERT (book.CanAppend()); book.AddNew(); book.m_BookTitle = dlg...

Analytical Accounting Error #2
Dear All, I am facing problem regarding Analytical Accounting. while entering inventory adjustment and click on distribution and then click on Analytical Accounting button the following error appear "No distribution have created" please advice Hi Tareq If this is version 9 I think there is a Hotfix fix that will correct this. Fliehigh "Eng. Tareq Sabri" wrote: > Dear All, > > I am facing problem regarding Analytical Accounting. > while entering inventory adjustment and click on distribution and then click > on Analytical Accounting button the follow...

time table #2
hi my name is Muhammad Habib.i wana make a time table in excel.but i am confused.i make in this way that when i change the one entry of timming of coledge the other entries are changed regardingly.can any person help me? regards, muhammad I realise that English is not your first language but could you try to explain what it is that you want a bit more. -- Regards, Sandy In Perth, the ancient capital of Scotland and the crowning place of kings sandymann2@mailinator.com Replace @mailinator.com with @tiscali.co.uk "Muhammad" <Muhammad@discussions.microsoft.com> wrote in...

Recipient Filtering in Exchange 2003 #2
I've read M$ article 823866 and I'm looking at enabling Recipient Filtering. Has anybody tested/enabled this feature in Exchange 2003? Are their any "gotchas" I need to look out for? Does this feature increase CPU load - I figure it might as the server must now query a GC *during the SMTP conversation* to verify that the recipient address is in the GAL. Are their any negatives with regard to this setting? Does it aid spammers, perhaps, with Directory Harvest Attacks? Just making sure to dot my i's and cross my t's before moving forward. Thanks for any responses...

Calculating Time #2
Hello, I know there have been other posts on this subject, but I can't find anything that answers the question that I have. I'm working on a time card spreadsheet. The format is as follows... E7 Time in / F7 Time Out Lunch / G7 Time In Lunch / H7 Out I've been able to get the total time for each day to work in time format by using the following. Code: -------------------- =F7-E7+H7-G7 -------------------- Where I'm having trouble is that I'd like to add the total for each day to accumulate in cell D21 in decimal format, so that 8:30 will appear as 8.5. Is the...

combining data #2
I am trying to combine columns in my spreadsheet, eg, column 1 is fd column 2 is fz column 3 is mt column 4 is it column 5 is et column 6 is vg How do I make this look like: fdfzmtitetv -- Message posted from http://www.ExcelForum.com Hi try =A1&B1&C1&D1&E1&F1 -- Regards Frank Kabel Frankfurt, Germany > I am trying to combine columns in my spreadsheet, eg, > column 1 is fd > column 2 is fz > column 3 is mt > column 4 is it > column 5 is et > column 6 is vg > > How do I make this look like: fdfzmtitet...

Cannot install RMS 2.0 Service Pack 2
I have created a VM with Windows Server 2008 Standard Edition (SP2) in order to test on it the integration between GP and RMS (HQ and Store Operations). Currently I need to update RMS to Service Pack 2 because one of the store databases which I am using for testing was backed up from a system using RMS SP2. The problem is that when I am trying to install the service pack I am getting an error saying "The update cannot be applied". Any ideas why this could be happening? Any help is greatly appreciated. This is a multi-part message in MIME format. ------=_NextPart_...

different fonts when I concatenate #2
I am concatentating a group of Excel cells. The first cell has bold font and when I concatenate it, the bold disappears. Also, need to put a return in the formula to get second cell to go to next line. Can anyone help me? If you want to CONCATENATE say A1 and B1, put a space and an Alt-Return in a helper cell, say C1, then =A1&C1&B1 will give you your second line in the target cell........... If you want the BOLD, the only thing I know to do is to set the whole target cell to BOLD. Vaya con Dios, Chuck, CABGx3 "rivgrl85" <rivgrl85@discussions.microsoft.com> ...

Money 2006 on Vista Beta 2
Hi All, I know this isn't the Vista support group, but perhaps some of you have run into this. Money works great on Vista beta 2, except for this error when I update my accounts (Amex and Schwab, to be exact): An Internet Communication error occured... OFXIE12029. This works great on XP (with IE beta 2 also). Any ideas? I am not running Windows Firewall. The 12029 error is normally related to the program being unable to connect to the remote site, so could be firewall related - worth checking whether Money is allowed to get through it. -- Glyn Simpson, Microsoft MVP - Money h...

$997 PROFIT Per Order
See how you can earn thousands per day without ever picking up a phone. This opportunity is exploding right now. Work 1 on 1 with top earner. Get the details here www.0to20k.com ...

where do declare a variable?
Hello, Where do you think it is better to declare a variable? Before a loop or within? For example in the next 2 samples, variable pLin: //sample 1 POSITION pos = coll.GetHeadPosition(); while (pos != NULL) { QLin* pLin = coll.GetNext(pos); ... } //sample 2 QLin* pLin; POSITION pos = coll.GetHeadPosition(); while (pos != NULL) { pLin = coll.GetNext(pos); ... } Thanks for opinions Vaclav "Vaclav" <vjedlicka@atlas.cz> wrote in message news:OXexQuHLIHA.4712@TK2MSFTNGP04.phx.gbl... > Hello, > > Where do you think it is better to declare a varia...

Calculator #2
It seems there should be a calculator function in Excel. I'm often needing to add a few numbers together before inserting them. Anyone know of such a thing? There's no popup calculator built into Excel. People often just use a cell, typing for example, =1+2+3 and Enter. If you don't want a formula in the cell press F9 before the Enter. -- Jim Rech Excel MVP Excel IS a calculator, so of course no one needs one ;-) .... but anyway, Orlando has one at http://cpap.com.br/orlando/ and John has one at http://j-walk.com/ss/excel/files/toolbarcalc.htm -- HTH. Best wishes Haral...

REPORT PROBLEM #2
When I try to request A transactions by category report, I get "MONEY HAS ENCOUNTERED A PROBLEM AND NEEDS TO CLOSE." All transactions are MATCHED AND ENTERED IN MY REGISTERS. I can't figure out what is causing the program to close. ...

DOCTYPE Declaration using XmlSerializer
Can any one let me know how I can DOCTYPE (DTD declaration) to the XML generated by XmlSerializer raj wrote: > Can any one let me know how I can DOCTYPE (DTD declaration) to the XML > generated by XmlSerializer Why do you need a DTD, with XML serialization there is a mapping between ..NET types and W3C XML schema types so there is no need for a DTD as the schema describes the structure and types of the serialized XML. -- Martin Honnen http://JavaScript.FAQTs.com/ I need to send this XML to a website, which is expecting the DOCTYPE declaration in the xml. "Martin Hon...

Adjusting W-2 information
Two of the employees here went on short term disability. When our insurance company paid the benefits to the employees directly, they took out FICA withholding and paid the IRS. We have to run the first 2008 payroll before we can adjust these numbers. How do we adjust the W-2 information for the employees so the W-2, Form 941 report information, and the historical payroll totals so they are correct in GP? Any information is appreciated. Thanks in advance. -Joe ...

Office 4.2.1 and OS 9.2.2
Can I use this version of Office which I had with 8.1. Just upgraded to 9.2.2 and it says "Microsoft dialog library not found". > Can I use this version of Office which I had with 8.1. > Just upgraded to 9.2.2 and it says "Microsoft dialog > library not found". It's not compatible. You'll have to upgrade to (at least) Office 98 or downgrade to Mac OS 8.6. See: http://support.microsoft.com/default.aspx?scid=kb;en- us;288769 -- Bernard Rey MVP office:macintosh ...

Templates #2
I am trying to create a template for a newsletter on P2000. Is it true that Microsoft forces you to use their template folder? Can't seem to save it elsewhere. A small child turns to Ed, and exclaims: "Look! Look! A post from Builder <dovbaer353@yahoo.com>!"... > I am trying to create a template for a newsletter on P2000. Is it > true that Microsoft forces you to use their template folder? Can't > seem to save it elsewhere. If you want to save the file as a template that can be used to create future publications from by using New > From Template, the te...

Error :The root element of a W3C XML Schema should be <schema>
Hi, I am getting following error while validating xml file with schema using ReaderSettings in .NET 2.0 "Line: 0 - Position: 0 - The root element of a W3C XML Schema should be <schema> and its namespace should be 'http://www.w3.org/2001/XMLSchema'." First few lines of xsd file are as follows: <?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.keaneaustralia.com/Nts" elementFormDefault="qualified" targetNamespace="http://schemas.kean...

ERROR 1100009 #2
Afetr my system installed SP2 some of my Publisher files will not open. I have am Error 1100009. I installed the hotfix from Microsoft yet it still does not work. Any suggestions The hotfix is the only solution to error 1100009. Are you sure you have installed it correctly? -- Mary Sauer http://msauer.mvps.org/ "Taylor" <Taylor@discussions.microsoft.com> wrote in message news:F2B06E04-72D9-4903-92A4-B1988B6F0830@microsoft.com... > Afetr my system installed SP2 some of my Publisher files will not open. I > have am Error 1100009. I installed the hotfix from Mic...

RichEdit #2
Hi guys it is me again, my application lunches a modeless dialog, which is basically created using the resource editor. Adding controls i.e. buttons dispalys OK with the modeless dialog. But, when I add the a RichEdit2 control the application asserts. it is launched using the following lines: //Spawn the dialog Window m_pModelessViewDlg = new CStdioViewDlg(AfxGetMainWnd()); m_pModelessViewDlg->Create(CStdioViewDlg::IDD, AfxGetMainWnd()->GetDesktopWindow()); m_pModelessViewDlg->ShowWindow(SW_SHOW); the Dialog is basically: IDD_DIALOG1 DIALOGEX 0, 0, 186, 90 STYLE DS_SETFONT | DS_...

XML Serialization with Namespace Declaration
Hi, I hava strong typed classes generated from a xsd-file with the root object: /// <remarks/> [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.ipdr.org/namespaces/ipdr_3_0")] public class IPDRDoc { ... } and some "child objects" ,uses the same namespace. Now I serialize a object from this class with XmlTextWriter to a file and with included "SoapSerializer" to a SOAP-Message for a WebService. In both xml�s the root element don�t have the needed namespace declaration !! But All Child-Elements has their namespace declaration. Why doe...

ip addresses #2
Could someone please tell me how I can see who is on the other end of a ip address that showed up on a ISA report. Hi - this is a Microsoft Outlook newsgroup; not the best place for your question. Try an ISA group or one that's more relevant...you can also look up the owner of the netblock/IP address at www.arin.net/whois or try ping -a xxx.xxx.xxx.xxx from a command prompt if you just want to see the reverse lookup entry in DNS. tammymac wrote: > Could someone please tell me how I can see who is on the > other end of a ip address that showed up on a ISA report. ...

V-lookup #2
Hi All I am totally lost I am trying to setup a dropdown list in excel,so that when i select something from the drop down list it retrieves information from other cells and places it somewhere else E.G. I want the drop down list to appear on sheet one with country names, which i have entered in coumn F on sheet tw Where f4 = france f5 = ireland, also on sheet two i have the french for street(RUE),city(CITE),country(PAYS),and postal code(CEDEX) in cells a4,a7 which i want to appear in cells d13,d16 on sheet one when i select france on the drop down list and when i select ireland on the drop ...

Copy from Excel and Paste into Outlook #2
Hi all, I am trying to automate the following procedure, but I have no clue as how to do it. Could you please advise? I have a spreadsheet, and I want to copy the contents of a Range, WITH formatting, and paste them into an HTML Email on Outlook. How do I do it with VBA? Thanks Alessandro One method that might help is documented here: = http://www.outlookcode.com/threads.aspx?forumid=3D2&messageid=3D20232 Also, the method shown here -- = http://www.outlookcode.com/codedetail.aspx?id=3D1333 -- is for Word, but = can also be used in Excel. You could, for example, copy and paste the ...