| Author |
Message |
   
Sopathi
Junior Artist Username: Sopathi
Post Number: 696 Registered: 02-2008 Posted From: 63.119.227.6
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 05:43 pm: |
    |
Sopathi:rect * const p1; p1 = &i; //this is what happens internally.
Typo, you cannot assign new address to const pointer after declaration of the const pointer. so, it should be like this, rect * const p1 = &i //this is what happens internally. Dravidians ki 12% BOKKA because Bayyas breed like &*%$ |
   
Sopathi
Junior Artist Username: Sopathi
Post Number: 695 Registered: 02-2008 Posted From: 209.172.101.244
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 05:37 pm: |
    |
Typo, rect i; rect & ir = i; //typo here compiler creates a hidden const pointer(say p1) to type 'rect' and points it to 'i'. p1 represents `ir` internally. rect * const p1; p1 = &i; //this is what happens internally. when you say ir.length = 3; what really happens is this, (*p1).length = 3; so end result will be "i.length = 3" when you say, &ir , this is what happens, &(*p1) so you can never find out the address location of the reference although its stored in the memory as a const pointer. Dravidians ki 12% BOKKA because Bayyas breed like &*%$ |
   
Sopathi
Junior Artist Username: Sopathi
Post Number: 694 Registered: 02-2008 Posted From: 63.119.227.6
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 05:36 pm: |
    |
rect i; rect ir = i; compiler creates a hidden const pointer(say p1) to type 'rect' and points it to 'i'. p1 represents `ir` internally. rect * const p1; p1 = &i; //this is what happens internally. when you say ir.length = 3; what really happens is this, (*p1).length = 3; so end result will be "i.length = 3" when you say, &ir , this is what happens, &(*p1) so you can never find out the address location of the reference although its stored in the memory as a const pointer. Dravidians ki 12% BOKKA because Bayyas breed like &*%$ |
   
Jodhaa
Side Hero Username: Jodhaa
Post Number: 4301 Registered: 02-2008 Posted From: 208.11.223.20
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 05:14 pm: |
    |
Mclovin:Operator Overloading emo choodu.. almost 9yrs ayyindi sesi..
Indra:adhii declaration of reference to an int. kaani its required to be initialised to something like rect & a1= i;
 No one can make you feel inferior without your permission, remember they are no better |
   
A_beautiful_mind
Junior Artist Username: A_beautiful_mind
Post Number: 29 Registered: 05-2008 Posted From: 128.221.197.20
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 05:13 pm: |
    |
Sopathi:nt i; int &ir = i; &ir will give you address of i &ir will be same as &i but you can never find out the real address location for the const pointer internally created to represent ir.
u got it ..i am going to correct it |
   
Sopathi
Junior Artist Username: Sopathi
Post Number: 693 Registered: 02-2008 Posted From: 209.172.101.244
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 04:48 pm: |
    |
Mandharam:
int i; int &ir = i; &ir will give you address of i &ir will be same as &i but you can never find out the real address location for the const pointer internally created to represent ir. Dravidians ki 12% BOKKA because Bayyas breed like &*%$ |
   
Mandharam
Junior Artist Username: Mandharam
Post Number: 458 Registered: 02-2008 Posted From: 122.167.68.48
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 03:17 pm: |
    |
Sopathi:references are NOT replaced at compile time.
yup ..thanks bro >>>>>>>>>>>>>>>>NIL BULLS<<<<<<<<<<<<< |
   
Sopathi
Junior Artist Username: Sopathi
Post Number: 692 Registered: 02-2008 Posted From: 209.172.101.244
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 02:53 pm: |
    |
Mandharam:Reference is a static concept and will be resolved during compile time. That means , the compiler would replace all the aliases to a variable after resolving all the dependencies..
dont think so. references are internally stored as const pointers. so yes the original data is not duplicated but the reference object is allocated memory as const pointer to that data. But you can never find the address location where the reference is stored as const pointer. C++ does not provide any operator to find the address where reference is stored. references are NOT replaced at compile time. Dravidians ki 12% BOKKA because Bayyas breed like &*%$ |
   
Mandharam
Junior Artist Username: Mandharam
Post Number: 457 Registered: 02-2008 Posted From: 122.167.68.48
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 02:29 pm: |
    |
Ideal_brain:
thnxx boss >>>>>>>>>>>>>>>>NIL BULLS<<<<<<<<<<<<< |
   
Ideal_brain
Junior Artist Username: Ideal_brain
Post Number: 35 Registered: 03-2008 Posted From: 192.147.58.6
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 02:27 pm: |
    |
The reference variables should always be assigned to variable when it i created. It is actually used in the the pass by reference because of the ease of use. You dont have to use * and & in the function code when you pass the reference. If you want more I will have to look at the book and can get back in the evening. |
   
Mandharam
Junior Artist Username: Mandharam
Post Number: 456 Registered: 02-2008 Posted From: 122.167.68.48
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 02:18 pm: |
    |
Mclovin:
Reference is a static concept and will be resolved during compile time. That means , the compiler would replace all the aliases to a variable after resolving all the dependencies.. Whereas ..pointer concept is dynamic..compiler is never sure which location a pointer can refer to...it can keep changing during run-time...dynamically.. Suppose int a=10,b=12 int *p = &a; //p is pointer to a int &r =a;//r is reference to a In both the cases, there is only 1 memory location allocated to store the integer variable.. The difference comes ...When there is another memory location which is needed in case of pointers to hold the address of the variable... This extra memory location is no needed for a reference...Hope u got this point >>>>>>>>>>>>>>>>NIL BULLS<<<<<<<<<<<<< |
   
Mclovin
Side Hero Username: Mclovin
Post Number: 7070 Registered: 02-2008 Posted From: 69.45.100.129
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 02:10 pm: |
    |
Mandharam:just go thru ..example quoted by PKfans anna
Kindi example lo ekkada difference anpichhindi neeku? I see reference has some limitation, that a reference in c++ can only have one value.. and cannot have NULL value.. In this db, there's always someone watching you!!  |
   
Mandharam
Junior Artist Username: Mandharam
Post Number: 455 Registered: 02-2008 Posted From: 122.167.68.48
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 02:07 pm: |
    |
Mclovin:It looks like Reference and Pointers will differ when talking about classes and objects rather than simple interger assignments.
Annayya...References and pointer differ even for integer variables... just go thru ..example quoted by PKfans anna >>>>>>>>>>>>>>>>NIL BULLS<<<<<<<<<<<<< |
   
Pkfans
Junior Artist Username: Pkfans
Post Number: 71 Registered: 04-2007 Posted From: 67.88.218.250
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 02:07 pm: |
    |
Mclovin:It looks like Reference and Pointers will differ when talking about classes and objects rather than simple interger assignments.
concept same is here replace integer with objects. |
   
Pkfans
Junior Artist Username: Pkfans
Post Number: 70 Registered: 04-2007 Posted From: 67.88.218.250
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 02:06 pm: |
    |
Mandharam:anna..nuvvu c++ stud la vunnav mail id ivva raadhe??
pkfans7@gmail.com |
   
Mclovin
Side Hero Username: Mclovin
Post Number: 7067 Registered: 02-2008 Posted From: 69.45.100.129
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 02:04 pm: |
    |
Pkfans:
It looks like Reference and Pointers will differ when talking about classes and objects rather than simple interger assignments. In this db, there's always someone watching you!!  |
   
Mandharam
Junior Artist Username: Mandharam
Post Number: 454 Registered: 02-2008 Posted From: 122.167.68.48
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 02:04 pm: |
    |
Pkfans:
anna..nuvvu c++ stud la vunnav mail id ivva raadhe?? >>>>>>>>>>>>>>>>NIL BULLS<<<<<<<<<<<<< |
   
Mandharam
Junior Artist Username: Mandharam
Post Number: 453 Registered: 02-2008 Posted From: 122.167.68.48
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 02:03 pm: |
    |
Pkfans:
exactly!! >>>>>>>>>>>>>>>>NIL BULLS<<<<<<<<<<<<< |
   
Pkfans
Junior Artist Username: Pkfans
Post Number: 69 Registered: 04-2007 Posted From: 67.88.218.250
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:58 pm: |
    |
Mclovin:Pointers ante passing the value by referrence kadaa.. Say, a = 10 b = &a So, a address b lo store ayyindi and hence, a em chooste, b kooda ade choostadi. Deeniki C++ References ki thedaa hemtee? PS: nenu c++ chesi around 9yrs ayyindi.. so khangaaru padaku, naa kochhens soosi..
Don;t worry babai 8 year C++ lo unaanu here concept is different... int a=10,c=12 int *b = &a; b = &c; b=NULL; ikkada b is pointer which stored the address of the a and next statement it stored address of c. It means pointer can store any int variable address and b also stored NULL address. Reference int a =10,c=10; int &b =a; b= &c //this is invalid b=NULL //this is invalid Reference variable is alias of the existing varibale. In the above example b is reference to variable a means b is another name to the variable or duplicate name or alias. Reference must assign to variable during declaration. It cannot reference other variable during its scope. or it never be NULL. b=&c b=NULL are invlaid statements. |
   
Mandharam
Junior Artist Username: Mandharam
Post Number: 452 Registered: 02-2008 Posted From: 122.167.68.48
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:57 pm: |
    |
Mclovin:
C++ references is a different thing entirely..unlike pointers,it is just an alias to an existing variable.. Eg. float total = 100; float & sum = total; now we can use either of the names to operate on the float variable. The catch is ..any reference has to be initialised during declaration ...which isn't the case with my issue >>>>>>>>>>>>>>>>NIL BULLS<<<<<<<<<<<<< |
   
A_beautiful_mind
Junior Artist Username: A_beautiful_mind
Post Number: 28 Registered: 05-2008 Posted From: 128.221.197.20
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:54 pm: |
    |
I have compiled some intervieq c,c++ interview q's here http://blog.360.yahoo.com/blog-1ViKHp06aKQOW02wZ.Cpozw-?cq=1 |
   
Mandharam
Junior Artist Username: Mandharam
Post Number: 451 Registered: 02-2008 Posted From: 122.167.68.48
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:51 pm: |
    |
Mclovin:article sadivaa.. still c pointers ki, c++ references ki theda artham kaaledu..
Thanxx ..MClovin and Pkfans ..also webbugger.. C++ reference ani artham ayyindi...i'll dig into it now >>>>>>>>>>>>>>>>NIL BULLS<<<<<<<<<<<<< |
   
Mclovin
Side Hero Username: Mclovin
Post Number: 7064 Registered: 02-2008 Posted From: 69.45.100.129
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:46 pm: |
    |
Pkfans:
Pointers ante passing the value by referrence kadaa.. Say, a = 10 b = &a So, a address b lo store ayyindi and hence, a em chooste, b kooda ade choostadi. Deeniki C++ References ki thedaa hemtee? PS: nenu c++ chesi around 9yrs ayyindi.. so khangaaru padaku, naa kochhens soosi.. In this db, there's always someone watching you!!  |
   
A_beautiful_mind
Junior Artist Username: A_beautiful_mind
Post Number: 27 Registered: 05-2008 Posted From: 128.221.197.20
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:45 pm: |
    |
Mclovin:article sadivaa.. still c pointers ki, c++ references ki theda artham kaaledu..
http://www.parashift.com/c++-faq-lite/references.html#faq-8. 6 |
   
Pkfans
Junior Artist Username: Pkfans
Post Number: 68 Registered: 04-2007 Posted From: 67.88.218.250
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:41 pm: |
    |
Mclovin:article sadivaa.. still c pointers ki, c++ references ki theda artham kaaledu..
exactly ekkada artham kaledu chepthey i will try to explain. |
   
Mclovin
Side Hero Username: Mclovin
Post Number: 7063 Registered: 02-2008 Posted From: 69.45.100.129
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:40 pm: |
    |
A_beautiful_mind:it is different concept altogether
article sadivaa.. still c pointers ki, c++ references ki theda artham kaaledu.. In this db, there's always someone watching you!!  |
   
Pkfans
Junior Artist Username: Pkfans
Post Number: 67 Registered: 04-2007 Posted From: 67.88.218.250
Rating:  Votes: 1 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:36 pm: |
    |
Indra:adhii declaration of reference to an int. kaani its required to be initialised to something like rect & a1= i;
example: rect j rect &r =j here j is the intance of the class rect. where as r is reference of the object j or alias name of the object j. |
   
Indra
Side Hero Username: Indra
Post Number: 5596 Registered: 12-2006 Posted From: 68.84.160.253
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:34 pm: |
    |
Mandharam:Rectangle & a1;
adhii declaration of reference to an int. kaani its required to be initialised to something like rect & a1= i; |
   
A_beautiful_mind
Junior Artist Username: A_beautiful_mind
Post Number: 26 Registered: 05-2008 Posted From: 128.221.197.20
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:33 pm: |
    |
Mclovin:Pointer antene passing by reference kadaaaaa..
it is different concept altogether http://www.cprogramming.com/tutorial/references.html |
   
Pkfans
Junior Artist Username: Pkfans
Post Number: 66 Registered: 04-2007 Posted From: 67.88.218.250
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:33 pm: |
    |
A_beautiful_mind:This declartion is wrong i guess ..it should be int x; int& foo = x;
correct..it is reference variable which should be assign during the declaration. Reference just alias of the existed variabe. |
   
Mclovin
Side Hero Username: Mclovin
Post Number: 7062 Registered: 02-2008 Posted From: 69.27.233.254
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:32 pm: |
    |
Pointer antene passing by reference kadaaaaa.. In this db, there's always someone watching you!!  |
   
A_beautiful_mind
Junior Artist Username: A_beautiful_mind
Post Number: 25 Registered: 05-2008 Posted From: 128.221.197.20
Rating:  Votes: 1 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:31 pm: |
    |
Mandharam: FYI this is just the declaration part..
This declartion is wrong i guess ..it should be int x; int& foo = x; |
   
A_beautiful_mind
Junior Artist Username: A_beautiful_mind
Post Number: 24 Registered: 05-2008 Posted From: 128.221.197.20
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:28 pm: |
    |
Mandharam:Rectangle & a1
c++ lo passing by reference ane concept vundi .in addition to pasiing by value and pointer. This is passing by reference |
   
Mandharam
Junior Artist Username: Mandharam
Post Number: 450 Registered: 02-2008 Posted From: 122.167.68.48
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:06 pm: |
    |
Webbugger:
FYI this is just the declaration part.. >>>>>>>>>>>>>>>>NIL BULLS<<<<<<<<<<<<< |
   
Webbugger
Junior Artist Username: Webbugger
Post Number: 395 Registered: 03-2008 Posted From: 164.54.210.16
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 01:05 pm: |
    |
Mandharam:Rectangle & a1;
this is used when you are passing the object to a function...when you are not working with pointers you will directly pass the address to the function... http://www.andhrastage.com http://www.indiastage.com |
   
Mclovin
Side Hero Username: Mclovin
Post Number: 7057 Registered: 02-2008 Posted From: 69.45.100.129
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 12:41 pm: |
    |
Operator Overloading emo choodu.. almost 9yrs ayyindi sesi.. In this db, there's always someone watching you!!  |
   
Mandharam
Junior Artist Username: Mandharam
Post Number: 449 Registered: 02-2008 Posted From: 122.167.68.48
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 12:40 pm: |
    |
 >>>>>>>>>>>>>>>>NIL BULLS<<<<<<<<<<<<< |
   
Mandharam
Junior Artist Username: Mandharam
Post Number: 447 Registered: 02-2008 Posted From: 122.167.68.48
Rating: N/A Votes: 0 (Vote!) | | Posted on Wednesday, July 23, 2008 - 12:34 pm: |
    |
Rectangle r1; //this is normal declaration of an instance for a class Reactangle *p1; //this is declaring a pointer to an object of type Rectangle What is this then ??? Rectangle & a1; >>>>>>>>>>>>>>>>NIL BULLS<<<<<<<<<<<<< |