typedef

  • Thread starter Thread starter George3
  • Start date Start date
G

George3

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 said:
#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
 
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
 
Tamas said:
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.
 
Back
Top