473,395 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Can a reference to an array be written without a typedef?

This is valid C++:

float s0[3];

typedef float array3[3];
array3& s1 = s0;

This creates a reference to an array.
Can the two statements be written without a typedef? Thanks.

John Nagle

Aug 1 '08 #1
4 1656

"John Nagle" <na***@animats.comwrote in message
news:48***********************@news.sonic.net...
This is valid C++:

float s0[3];

typedef float array3[3];
array3& s1 = s0;

This creates a reference to an array.
Can the two statements be written without a typedef? Thanks.
float(& s1)[3] = s0;

regards
Andy Little
Aug 1 '08 #2

"John Nagle" <na***@animats.comwrote in message
news:48***********************@news.sonic.net...
This is valid C++:

float s0[3];

typedef float array3[3];
array3& s1 = s0;

This creates a reference to an array.
Can the two statements be written without a typedef? Thanks.
Try:
float (&s1)[3] = s0;

Aug 1 '08 #3
John Nagle wrote:
This is valid C++:

float s0[3];

typedef float array3[3];
array3& s1 = s0;

This creates a reference to an array.
Can the two statements be written without a typedef? Thanks.
In addition to responses else-thread, I think that in C++0x you will be
able to do this:

float s0[3];

decltype(s0) & s1 = s0;
--
Fran
Aug 1 '08 #4
In article <u3***********@not.available>,
Francis Litterio <em***@not.availablewrote:
>John Nagle wrote:
>This is valid C++:

float s0[3];

typedef float array3[3];
array3& s1 = s0;

This creates a reference to an array.
Can the two statements be written without a typedef? Thanks.

In addition to responses else-thread, I think that in C++0x you will be
able to do this:

float s0[3];

decltype(s0) & s1 = s0;
Yes, that's fine too.
--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Aug 1 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Kristian Bisgaard Lassen | last post by:
Hi, How do I parameterize a template by a a allocated array of integers, which is declared static and constant, so I can make compile time optimizations depending on the content of the array....
5
by: Steve | last post by:
Can anyone tell me if I can have an array of functions that take a variable number of parameters? If it is possible I'd like to know how to declare the array and the functions as its elements. I am...
32
by: Mateo | last post by:
I have char *array and it is dinamically alocated.... When I pass it to other function, I need to determine size of this array.... Problem: sizeof operator does not work with dinamically alocated...
16
by: Frederick Gotham | last post by:
Inspired by page 219 of Nicolai M. Josuttis's book, I set out to write a class for an intrinsic array which would behave, to as far an extent as possible, like a container. Also though, I wanted no...
1
by: peary | last post by:
Hi, everyone, I'm writing a program to discover wireless network using Windows Native Wifi API & VB.net. I have to declare the windows API in my VB.net program. The original windows...
12
by: estantep | last post by:
Hello, I am having some trouble trying to pass a pointer to an structure array (as function argument), when executing I get seg faults. The best I could get out from googling was: #define...
19
by: Eugeny Myunster | last post by:
I know, only simple one: #include <stdio.h> int main() { int min=0,max=0,i,arr; for(i=0;i<12;i++) arr=rand()%31-10; for(i=0;i<12;i++)
8
by: S. | last post by:
Hi all, Can someone please help me with this? I have the following struct: typedef struct { char *name; int age; } Student;
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.