|
Hi Iain,
This is what you mentioned in your long post,
Iain Clarke wrote: Suddenly, you have a bug that doesn't manifest until much later, and would be really hard to track down.
I have re-read your code, but I can not see any bugs. It is appreciated if you could point out.
If you mean the input parameter should be defined as non-const reference, I do not think it is a bug, it is a design and function limitation.
regards,
George
|
|
|
|
|
The bug is the DoSomethingNotConst () being called in the operator = function, and the compiler not telling you off, because you hadn't consted the reference(s) in the operator= function.
In the following snippet
Class C a,b;
b.FillWithValues ();
a = b;
you would expect a = b to not change b at all.
And if you write the copy constructor using a const reference, then it is harder to mess up and make that mistake. That's all. The const keyword just makes it that bit harder for you to mess up.
If you're a super programmer who never makes mistakes, and remembers the reason for every line of code you've ever written, then you never need the const keyword at all.
Guess what. You're not that super programmer. Neither am I.
const is like a sports cup. It makes it that bit harder to have a nasty injury.
Iain.
|
|
|
|
|
Thanks Iain,
My question is answered. You are a super developer whose thoughts are not easily caught.
regards,
George
|
|
|
|
|
I downloaded a slip code from http://support.microsoft.com/kb/308669[^].And build a console project and insert the source files in VS2005.
But there are such errors occured like bellow:
1>main2.obj : error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function "void __cdecl DebugPrint(unsigned short,char *,...)" (?DebugPrint@@YAXGPADZZ)
1>main2.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function "void __cdecl DebugPrint(unsigned short,char *,...)" (?DebugPrint@@YAXGPADZZ)
1>main2.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
1>main2.obj : error LNK2001: unresolved external symbol __RTC_InitBase
1>main2.obj : error LNK2019: unresolved external symbol __imp__SetupDiDestroyDeviceInfoList@4 referenced in function _main
1>main2.obj : error LNK2019: unresolved external symbol __imp__SetupDiGetClassDevsA@16 referenced in function _main
1>main2.obj : error LNK2019: unresolved external symbol __imp__CM_Reenumerate_DevNode@8 referenced in function "int __cdecl GetRegistryProperty(void *,unsigned long)" (?GetRegistryProperty@@YAHPAXK@Z)
1>main2.obj : error LNK2019: unresolved external symbol __imp__SetupDiGetDeviceRegistryPropertyA@28 referenced in function "int __cdecl GetRegistryProperty(void *,unsigned long)" (?GetRegistryProperty@@YAHPAXK@Z)
1>main2.obj : error LNK2019: unresolved external symbol __imp__CM_Get_Device_IDA@16 referenced in function "int __cdecl GetRegistryProperty(void *,unsigned long)" (?GetRegistryProperty@@YAHPAXK@Z)
1>main2.obj : error LNK2019: unresolved external symbol __imp__SetupDiEnumDeviceInfo@12 referenced in function "int __cdecl GetRegistryProperty(void *,unsigned long)" (?GetRegistryProperty@@YAHPAXK@Z)
1>main2.obj : error LNK2019: unresolved external symbol __imp__SetupDiGetDeviceInterfaceDetailA@24 referenced in function "void __cdecl GetInquiryData(char const *)" (?GetInquiryData@@YAXPBD@Z)
1>main2.obj : error LNK2019: unresolved external symbol __imp__SetupDiEnumDeviceInterfaces@20 referenced in function "void __cdecl GetInquiryData(char const *)" (?GetInquiryData@@YAXPBD@Z)
1>main2.obj : error LNK2019: unresolved external symbol __imp__CM_Get_Sibling@12 referenced in function "void __cdecl GetChildDevices(unsigned long)" (?GetChildDevices@@YAXK@Z)
1>main2.obj : error LNK2019: unresolved external symbol __imp__CM_Get_Child@12 referenced in function "void __cdecl GetChildDevices(unsigned long)" (?GetChildDevices@@YAXK@Z)
And I also include <stdarg.h>,<rtcapi.h> in the code.
Someone would like to tell me,how to resolve such errors?
Thanks.
GOOD LUCK
|
|
|
|
|
All linker errors. Are you missing an import library or two in your
project settings?
setupapi.lib should take care of the SetupDi___ externals. I'm not sure
about the top four
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your reply.
I search the four errors every where,but the questions seems to laying every where,but no answer!
I only want to get a usb device's SCSI data,so I have to use IOCTL_SCSI_GET_INQUIRY_DATA to send a query request to the device's driver.In a word,the device's firmware datas I want to retrieve.
The code was download from microsoft!
Thank you once again.
Best wishes.
|
|
|
|
|
There wasn't a project or makefile with the code?
I wonder if it's part of the device driver sdk (DDK)...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I also agree with you.
My PC has DDK installed,too.
I think the problem is that,all of us don't know what lib files should import.
I hope,the problem would be resolved.
Best regards.
|
|
|
|
|
add Mark Salsbery Comment
All linker errors. Are you missing an import library or two in your
project settings?
you need add hid.lib setupapi.lib in menu Project\project settings slect L ink and add
hid.lib setupapi.lib in to Object. Libary modules
i have same Problem as you ,and i resolved it
|
|
|
|
|
Hi Friends,
Could any one tell me, How to count number of files in a folder.
Ex:
C:\My Documents\New Folder
I need to count all the files in this path.
Thanks and Regards.
SANTHOSH V
|
|
|
|
|
you can use _findfirst() and _findnext().
The second function use the return value of the first function to retrieve.
You can see more details in MSDN.
But you should pay attention to the two found results,whose name is "." and "..",they are the current folder and its parent folder!
You can test in MS-DOS.
|
|
|
|
|
Thank you friend,
This _findfirst() and _findnext() helped me solve this problem.
Thanks a lot once again.
Thanks and Regards.
SANTHOSH V
|
|
|
|
|
If you are using DlgDirList you can get count of files.
|
|
|
|
|
Hi all,
Actually the searching criteria is changed in codeproject, and i am unable to find the new one...Can anybody please tell me how to search a article for example(progress bar in mfc)
Thanks in advance
|
|
|
|
|
Now you have to use an expression to find out like this
AND, NOT, OR and grouping parentheses supported. Enclose phrases in quotes.
eg. CListCtrl; "Grid Control" ; ((C# AND NOT Grid) OR Spreadsheet)
Try this link it gives you info about progress bars
http://www.codeproject.com/KB/tree/progresshourglassfx.aspx[^]
Regards,
Pankaj Sachdeva
There is no future lies in any job but future lies in the person who holds the job
|
|
|
|
|
yes, even i experienced the same for a while. But I am getting pretty much used to it now.
If you want to see any articles in MFC, then you can find them on the left of the screen. its under the heading 'CHAPTERS'. under that, you go to 'platforms, frameworks & Libraries' and choose 'MFC'. You can also find the articles regarding MFC controls under the section 'Desktop Development'.
Or else, you can always use Google to find the articles here on CP. When I don't find the article that i am looking for with the search option here in CP, I use Google to search for the article. I put the key words in Google and Google gives me a direct link to the article. For example, to find the 'progress bar in MFC', i put the key words 'progress bar + MFC + codeproject' in Google and I get a direct link to articles explaining about progress bar in mfc on codeproject. you can easily navigate from there to find similar articles. Its a strange approach, but it works for me.
Regards,
Vijay.
|
|
|
|
|
Hi all,
I have two applications, console application with MFC support and MFC DLL application. I want to connect both those two application together. Console application gives the required data to DLL.
So how should I do it.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Hello again everyone
Before that i would like to tell u all that im really new and dumb to .NET. Hope you guys can help me. I tried to search the solution to my problem but still couldnt find anything.
What im trying to do is to create a really simple internet connection detection which is running under a win32 console. The program will detect if there is any connection to the internet, if yes then it will print yes. If no connection then it will print out no connection using printf() statement.
I know that the InternetGetConnectedState API can help me. but still im not so sure on how to use it. Really dumb me...the scenario is like this
I already link the VC++ project to the Wininet.lib since it required that lib and a header file called Wininet.h (as refered in MSDN). I try to code just by adding the header file to the source code
<br />
#include "stdio.h"<br />
#include "Wininet.h"<br />
void main()<br />
{<br />
}<br />
using the code above, compile, it generates more than 100 error which particularly made the compiler to stop compiling due to error exceeds 100. all of the errors come from the Wininet.h header file. The first error was "error C2061: syntax error:Identifier 'HINTERNET'. The question is, am i missing something. Does VC++ supports this API? I've search the internet (forums..etc) and all of them were implemented using C# or VB. Is there any source code samples using this API which can be run only in a simple win32 console application? Thank you everyone. Really appreciate any help. Thanks again.
|
|
|
|
|
Kogee San wrote: it generates more than 100 error which particularly made the compiler to stop compiling due to error exceeds 100. all of the errors come from the Wininet.h header file.
modify ur code as follows
#include "stdio.h"
#include <windows.h>
#include "Wininet.h"
void main()
{
}
|
|
|
|
|
wow. It really works. Thanks. Just wanna ask if you dont mind. Why do we need to add windows.h. I always see codes which add windows.h eventhough it is just a hello world printf statement. Just kinda curious. Thanks again.
|
|
|
|
|
Kogee San wrote: Why do we need to add windows.h.
This is because the Wininet.h file use some other data types such as LPVOID. This is defined in some other header files. For getting the definition of such items we need to include the windows.h
|
|
|
|
|
Kogee San wrote: I always see codes which add windows.h eventhough it is just a hello world printf statement.
Then those programs included it unnecessarily.
"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
|
|
|
|
|
Thanks guys for your help and comments. Really appreciate it.
|
|
|
|
|
Hello developers,
Can i define a class in header file and declare it in .cpp file if using template or do i have to define and declare in the same header file. I have got two classes so do i have to define and declare both in the same header file or is it possible to have different header file for both classes.
I am writing double linked list application. Now i have got two class LList and Node. Now when i simply use template and write the two classes under one file without defining it , then it works perfectly fine but when i try to define the two class seperately i am getting many errors. What should i do in this case ?
Any way out ?
ThankYou
|
|
|
|
|
When you split the two classes into two header files, did
you remember to #include the dependent header file in the one
that depends on it?
If these are template classes, there shouldn't be any code in
CPP files. Actual intances of the template class aren't created
until an object of the class is defined, so at that point the compiler
would need to see the code in the CPP file.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|