|
Thanks Matthew,
Your answer is general and it is appreciated if you could provide some ideas of how in my question the function prototypes and functions are matched.
regards,
George
|
|
|
|
|
Hi Experts,
What is mean by this statement ?
<br />
inline CMyClass& GetTreeCtrl()
{<br />
return m_shellTree;<br />
}<br />
|
|
|
|
|
inline means that the function is inlined (the compiler will replace a call to the function by the code of the function itself). Search for inline on google
The & means that the function returns a reference to the object instead of a copy of the object. By default, in C++ when you pass arguments to a function, you will in fact have a copy of the object, not the original object. The same with the return of the function: you will get a copy of the object. By using the reference, it means that you will get the original object, not a copy (so, if you modify it outside the class, it will be modified in the class also).
But I think your code is wrong: you forgot the class name (or is does it come from a header file ? If yes, the inline is not needed).
|
|
|
|
|
returning the variable by reference!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Hi Friends,
I am doing a UNICODE project,
Here i am using wchar_t * variable and i am taking name of the file from CString.GetBuffer().
Here i am getting the error C2440: 'initializing' : cannot convert from 'char *' to 'unsigned short *'
Please help me. Its urgent....
|
|
|
|
|
First, never ever use GetBuffer without having read the documentation. CString has casting operator so that you don't have to use GetBuffer. You should only use this function if you want access to the internal buffer of the CString. Read the doc carefully if you don't want nasty surprises in your code.
You should prefer the use of TCHAR instead of char or wchar. This way, everything is either char or wchar depending on the UNICODE settings and you don't have to worry about conversions.
Now, maybe you'll still need a conversion: what are you doing with this wchar string ?
|
|
|
|
|
santhoshv84 wrote: I am doing a UNICODE project,
Sure?
santhoshv84 wrote: Here i am getting the error C2440: 'initializing' : cannot convert from 'char *' to 'unsigned short *'
Probably you aren't doing a UNICODE build. check if the _UNICODE preprocessor symbol is defined for your project.
BTW: probably you don't need either to access CString internal buffer, hence avoid to call GetBuffer method.
BTW 2: maybe better to use generic text data, i.e. TCHAR insted of w_char .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi all, I am developing one application. In that i have created on report file which contains tables, titles and tree view list also by using HTML tags. I am opening this file in my application it self as another window.
There is no problem in opening this file if the file is small. If the file is big(here i mean to say if number of tables present in this file)then while opening this file my application is displaying a message "Cannot create unique tag, giving up". I am unable to understand this messages.
Can any one please tell me how to avoid this ???
|
|
|
|
|
Well, if you're developing the application, do a search for "Cannot create unique tag, giving up", then put a break point there, and see why it reaches that code?
We have no clue why you wrote that error message. Only your past self, and an examination of your code while it runs can help you.
Iain.
|
|
|
|
|
When numbers are larger than 15 significant figures the function atof() is losing precision. For example:
double dVal = atof( pszValue ); // where pszValue holds the string "1111111111111111"
dVal ends up with 1.11111111111111e+15 which equates to:
1111111111111110
Can anyone suggest a safer way to convert the char* to a double?
|
|
|
|
|
That's because atof returns a float (guess what the 'f' in the function name stands for ?). You could try by using stringstream from the STL:
stringstream ssVal;
double dValue;
ssVal << pszValue;
ssVal >> dValue;
Don't forget to #include <sstream> and to put using namespace std; at the top of your cpp file.
Forget what I say, I wasn't awake . If you look at the range of a double, you'll see that the accuracy (here)[^] is 14 or 15 digits. Your string contains much more digits than that. Now, if the number that you want to represent is an integer value, why don't you use an __int64 instead ?
But, I have a question: why do you need such an accuracy, why is it important ? In most of the cases, you won't need that accuracy.
|
|
|
|
|
Cedric Moonen wrote: That's because atof returns a float
yeah that's what I thought about too. Until I saw this in MSDN[^]. Why not name it atod in the first place?
|
|
|
|
|
Yeah, I realized that just after I posted. I updated my answer already.
|
|
|
|
|
Hello,
I have created one MFC Application for User login page. I have created 2 dialog boxes. One dialog box contains username and password, when i press Create new account button, there is another dialog box will open. There i have given the username, password and confirm password.
The problem is if i click the submit button in 2nd dialog, only one character has to be stored in the file.
I want to store the entire text in the file.
How can I do that?. Please help on this.
Thanks in advance.
|
|
|
|
|
can you paste the code on that part? so we will know what the error is.
|
|
|
|
|
Hello,
Thanks a lot for reply. I attached the source code below:
If i click the submit button the following code is executing.
--------------------------------------------------------------
FILE *fleCredentials;
try {
// Create a new file or open the existing one
fleCredentials = fopen("credentials.crd", "a+");
{
// Add the username to the file
//
fprintf(fleCredentials, "%s ", (LPCTSTR)m_Username);
// Add the password to the file
fprintf(fleCredentials, "%s\n", (LPCTSTR)m_Password);
}
// After using it, close the file
fclose(fleCredentials);
--------------------------------------------------------
|
|
|
|
|
What is the data type of m_Username and m_Password?
|
|
|
|
|
m_username and m_password are CString types.
|
|
|
|
|
If you use the debugger at that function to save the two files, I bet you get...
m_User = "user" and m_Pass = "pass" (I can't see your original code)
And then your text file will be....
userpass
with no way of know where one starts, and the other finishes...
Instead of CString, try using a fixed character array, and then saving that out. It will be much easier when you load it. It will have the restriction of only being able to have user names and passwords of a certain length, so don't make it too short!
Iain.
|
|
|
|
|
Try using GetBuffer() function for the CString objects in the fprintf statement?
|
|
|
|
|
No, don't do that at all. The GetBuffer() method should only be used when write access to the internal buffer is required. In this case, it is not. The LPCTSTR operator is all that's needed.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
How are you verifying that only two characters (one from each variable) exist in the file? Is this a Unicode application?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Could you please post the code snippet ?
Regards,
Paresh.
|
|
|
|
|
I have given the code snippet where i can get the problem.
|
|
|
|
|
How to edit subitems in a list view , i tried LVS_EDITLABELS but it allows to edit first column only.
Thanks & Regards
|
|
|
|