|
But you said you had not tried it! Did it actually work? It would not surprize me if it did; I have just never thought it would. A reference is basically a dereference pointer; that is the compiler dereferences it for you.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Just to make things clear:
There are 3 classes A,B and C
B and C are derived from A : A has a virtual fn Display() and an int variable is declared in each class i,j and k respectively.
** And yes each class has a constructor where i assign a value to the variable's i,j,k respectively.
When we use pointers we can call :
B b;
C c;
A* a=&c;
a->display();
a=&b;
a->display();
But when we use references :
B b;
C c;
A& a=c;
a.display();
a=b;
a.display();
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 7:09 Wednesday 14th June, 2006
|
|
|
|
|
Its known that a reference can't be re initalized. But i just wanted to know what is happening when compiling the code A& a=c;
SaRath.
"Don't Do Different things... Do Things Differently..."
Understanding State Pattern in C++
|
|
|
|
|
wrote: Its known that a reference can't be re initalized. But i just wanted to know what is happening when compiling the code A& a=c;
A reference holds the address of an object, but behaves syntactically like an object
Now come to point what happening in A& a=c; code
'a' holds the address of the 'c' and no need of dereferencing of 'a'
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
|
Can anybody tell me how to reduce the size OpenSSL LIB ie ssleay32.lib and libeay.lib.
Thanx in advance.
never say die
-- modified at 6:25 Wednesday 14th June, 2006
|
|
|
|
|
Do you have the source code ? You can remove stuff you don't need, optimise the build for size ( not speed ), etc.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Can i do the foll conversion...
char * str1="abc";
CString str2=;
str2=str1;
-- modified at 6:24 Wednesday 14th June, 2006
|
|
|
|
|
ofcourse if u haven't defined
_UNICODE
nave
|
|
|
|
|
did xactly as mentioned in d query..n checked str2(D CString Variable)..it was empty!!!
and wat exactly is meant by the _UNICODE suggestion??
|
|
|
|
|
this will work. The cstring have the = operator overloaded for LPCSTR
char * str1="abc";
CString str2 = str1;
and about _UNICODE. now when i checked the CString have = operator overloaded for LPCWSTR.
so it will work even if _UNICODE is defined.
nave
|
|
|
|
|
CString str2;
str2=str2+';'+ str1;
never say die
-- modified at 6:33 Wednesday 14th June, 2006
|
|
|
|
|
er..wat about str2?
and d 'str' u mentioned is CString/char*??
|
|
|
|
|
Yha it was my mistake.I have replaced str by str2
never say die
|
|
|
|
|
sunit5 wrote: str2=str2+';'+ str1;
isn't this the same to the more readable :
str2 += ';' + str1;
-- TTD --
|
|
|
|
|
strcpy(str2,str1.GetBuffer(str1.GetLength()));
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
|
|
|
|
|
strcpy doesnt work with CString!!tried dat!
|
|
|
|
|
use _tcscpy_s(VS 2005) or _tcscpy
never say die
|
|
|
|
|
Did you look at Shaw? we are really blind!!
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
|
|
|
|
|
Didn't work? can post the code please. And did you try the exact line which I've posted? without any change to it?
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
|
|
|
|
|
CString::GetBuffer() does return a regular C-Style string, so you might be using it wrong...
VuNic's code does work good...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
yep the exact line!!
and
CString str2;
char str1[3]="abc";
ERROR1:left of '.GetBuffer' must have class/struct/union type
ERROR2:'strcpy' : cannot convert parameter 1 from 'class CString' to 'char *'
|
|
|
|
|
Could you please post the complete block of code?
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[ ]--
[My Current Status]
|
|
|
|
|
VuNic wrote: str1.GetBuffer(str1.GetLength())
Remember to ReleaseBuffer() after getting the Buffer using GetBuffer()
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
char* str1 = “abc”;
CString str2 = str1;
What is the problem?
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|