Click here to Skip to main content
Click here to Skip to main content

Tagged as

Declare a reference for a two dimensional array without typecasting

, 25 Dec 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
This not so useful tip tells you how to declare a reference for a two dimensional array without needing to use typecasting.
int x[1][20];
int (*p)[20] = x;
 
Here p has become a reference to x.
Usually in most cases, we use:
int** p = (int**) x;
 
So, this tip gives you a hint about how to declare another reference for x without typecasting.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mukit, Ataul
Chief Technology Officer Rational Technologies
Bangladesh Bangladesh
C++ is not C with classes, JQuery is not Javascript, Google Search is not Learning, Design Patterns are not fashion, A code written in 2005 is not backdated just because it's 2015
Follow on   Twitter

Comments and Discussions

 
GeneralRe: Unfortunately, in the code I've seen both in the projects I ... PinmemberStefan_Lang3-Jan-12 2:57 
GeneralIn your case as It was mentioned x is an address and what th... PinmemberSiarheiY27-Dec-11 3:46 
GeneralRe: the first dimensions size can be anything FYKI PinmemberMukit, Ataul27-Dec-11 22:15 
GeneralReason for my vote of 4 maybe Stefan_Lang is right. Pinmemberyellowcrd26-Dec-11 18:56 
GeneralWhy do you say it's not useful? I'd say it is, especially si... PinmemberStefan_Lang5-Dec-11 22:19 
GeneralRe: Never thought of it that way about the second form taking ex... PinmemberMukit, Ataul6-Dec-11 17:50 
GeneralRe: Type casting is done implicitly.Isn't it? Pinmemberyellowcrd26-Dec-11 19:21 
Type casting is done implicitly.Isn't it?
GeneralRe: "P.S.: type casting, especially C-style casts, are always ba... PinmemberPIEBALDconsult3-Jan-12 2:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 25 Dec 2011
Article Copyright 2011 by Mukit, Ataul
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid