473,322 Members | 1,703 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,322 software developers and data experts.

typedef


Hello everyone,
In the following segment, it does not compile because const is
qualified on (the whole) type int& not on the near one int, right?
Code:
--------------------

#include <iostream>

using namespace std;

typedef const int& rcInt;
typedef int& int_ref_t;

int main()
{
rcInt ref = 0; // compile ok

const int_ref_t x = 0; // error C2440: 'initializing' : cannot convert from 'int' to 'int_ref_t'

return 0;
}

--------------------

thanks in advance,
George

--
George3
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Feb 19 '08 #1
3 954
George3 wrote:
#include <iostream>

using namespace std;

typedef const int& rcInt;
typedef int& int_ref_t;

int main()
{
rcInt ref = 0; // compile ok

const int_ref_t x = 0; // error C2440: 'initializing' : cannot convert from 'int' to 'int_ref_t'

return 0;
}

The type of `ref' is: int const &
The type of `x' is: int & const

This should point you to the right direction.

Tom
Feb 19 '08 #2
George,

You posted this question to microsoft.public.vc.language, and it was
already answered there. Do you realize that you are wasting people's time.

Pick a group where your question belongs to. If you must post it to
multiple groups, please crosspost. Had you crossposted this question,
the previous answers would have showed up here.

Multiposting causes the discussion to split between multiple groups.
Only crossposting ensures that the full discussion gets combined.

Tom
Feb 19 '08 #3
Tamas Demjen wrote:
George,

You posted this question to microsoft.public.vc.language, and it was
already answered there. Do you realize that you are wasting people's time.

Pick a group where your question belongs to. If you must post it to
multiple groups, please crosspost. Had you crossposted this question,
the previous answers would have showed up here.

Multiposting causes the discussion to split between multiple groups.
Only crossposting ensures that the full discussion gets combined.
Tamas:

If you wish to change George's behavior (a good idea, IMHO), you need to post in
microsoft.public.vc.language, because he only ever answers there.

However I have become convinced that George is not s simple multi-poster. Either
he is deliberately trying to disrupt these groups, or (as he claims) his posts
are being copied to this group without his knowledge. Recent duplicated posts in
this group are all "Posted via http://www.codecomments.com", whereas the
"original" posts in microsoft.public.vc.language are not.

--
David Wilkinson
Visual C++ MVP
Feb 19 '08 #4

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

Similar topics

2
by: joe | last post by:
hi, after reading some articles and faq, i want to clarify myself what's correct(conform to standard) and what's not? or what should be correct but it isn't simply because compilers don't...
14
by: dreamcatcher | last post by:
I always have this idea that typedef a data type especially a structure is very convenient in coding, but my teacher insisted that I should use the full struct declaration and no further...
4
by: Chris | last post by:
I've lurked around long enough... Time to interract =) I'm trying to make sense of the following. I can't quite wrap my head around what this is actually doing: ------------- typedef enum {...
15
by: Merrill & Michele | last post by:
typedef struct { WORD versionNumber; WORD offset; } MENUITEMTEMPLATEHEADER; This is from vol 5 of unnamed platform's programmer's reference. I could make this conforming by enclosing...
16
by: burn | last post by:
Hello, i am writing a program under linux in c and compile my code with make and gcc. Now i have 4 files: init.c/h and packets.c/h. Each header-file contains some: init.h: struct xyz {
12
by: vvv | last post by:
Hi All, Do we have anything in .NET which is equivalent to C++'s Typedef . Regards, Vasanth
6
by: Alex | last post by:
Hello people, I am getting errors from VS2003 when working with typedef'ed types. For example, assume that I have a type T, defined in a 3rd party include file based on some condition #if...
15
by: Ian Bush | last post by:
Hi All, I'm a bit confused by the following which is causing one of our user's codes fail in compilation: typedef struct SctpDest_S; 1) Is this standard ? 2) If so ( or even if not so ! )...
12
by: Googy | last post by:
Hi!! Can any one explain me the meaning of following notations clearly : 1. typedef char(*(*frpapfrc()))(); frpapfrc f; 2. typedef int (*(arr2d_ptr)()); arr2d_ptr p; 3. typedef int...
16
by: mdh | last post by:
A quick ? :-) question about Typedefs. There is a very brief discussion about this in K&R ( p146). Googling this group, there is a surprising dearth of questions about these. From one of the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.