Click here to Skip to main content
15,170,651 members

Comments by «_Superman_» (Top 84 by date)

«_Superman_» 4-Jul-18 22:36pm View
>> Is this because it is like writing:
>> list1.operator=(list2.operator=(list3.operator=(list4)))
That is correct.

>>But the insert method doesnt take p_itr as a parameter so it can not modify it, it takes a value pointed to by p_itr.
I was referring to what could be done with pre-processor macros like in this link - The OFFSETOF() macro - GeeksforGeeks[^]
But it probably does not apply here. You could try and debug the code to check what is actually happening.

>>Is operator=(const Player& other); a valid definition
In C++ it is not. In C, int is assumed as the return type if nothing is specified.
However this defeats the purpose since you're trying to make a copy of the object, unless you have a single integer argument conversion constructor.
«_Superman_» 6-Oct-17 0:58am View
I executed your code and got the output given below.
What is your question?

Enter the coordinates of point 1: 2.3
Enter the coordinates of point 2: 6.7

The slope of the line is = 0.93182

The slope intercept form is: y = 0.93182x + 2.35682
«_Superman_» 4-Oct-17 4:43am View
Definitely yes. But std::sort is tried and tested. Who knows how it is going to be optimized in future. Having said that, after experimenting, if the performance makes a huge difference, then would definitely get rid of std::sort.
«_Superman_» 4-Oct-17 4:34am View
I agree. For this case iterating once over the list would indeed be the fastest.
«_Superman_» 4-Oct-17 4:23am View
I would still prefer sort to having if conditions inside a loop.
«_Superman_» 4-Oct-17 0:46am View
I would disagree.
std::sort is there to use.
I believe this would be more optimized rather than iterating over a loop.
«_Superman_» 3-Oct-17 1:53am View
The implementations are compiler and platform dependent.
You could even get different results on different types of applications like Windows applications and console applications on Windows OS itself.
«_Superman_» 3-Oct-17 1:51am View
You should update your question rather than repeating.
«_Superman_» 1-Nov-16 0:18am View
Since you're using C++, I recommend you take at look at regular expressions (std::regex).
«_Superman_» 27-Oct-16 2:59am View
Read it as a string (character array) instead of character by character - scanf("%s", arr);
«_Superman_» 21-Mar-16 3:06am View
Try downloading and installing the Windows 7 SDK -
«_Superman_» 18-Mar-16 6:41am View
Do not post as a new solution.
Please comment to my solution and delete this.
«_Superman_» 15-Mar-16 1:26am View
What is the content of the space variable before invoking chdir?
Is that a valid path?
«_Superman_» 11-Mar-16 4:16am View
Unfortunately, I'm not familiar with RAD Studio.
You could check its project properties for any option where you can specify the library name.
Or you could check if the pragma works by giving this in some header file - #pragma comment(lib, "lib name")
Use the library path in place of lib name.
«_Superman_» 11-Mar-16 3:12am View
Please post what you have tried so far.
«_Superman_» 23-Oct-14 1:03am View
Beautifully explained. My 5.
«_Superman_» 14-Mar-14 1:37am View
No. -I is to specify the directory.
Assume gmpxx.h exists in the /usr/ethan/inc directory.
If you do a #include <gmpxx.h> in your code, you would need to use -I /usr/ethan/inc for the make command line.
«_Superman_» 11-Mar-14 1:11am View
It's basically the same error.
File not found for a #include means that you're not specifying the path where the file exists with the -I option.
«_Superman_» 11-Mar-14 1:09am View
I don't mean the usage of new and delete.
You can see the difference in how the myfunc function takes a reference to a char* and the syntactical differences because of that.
«_Superman_» 24-Feb-14 1:42am View
«_Superman_» 12-Feb-14 9:26am View
Check the value of nDelta. A negative value scrolls up and a positive value scrolls down.
«_Superman_» 11-Feb-14 2:02am View
I understand your question.
Native C++ does not support properties.
The way I put it is the closest you can get to the usage syntax of C# properties.
Otherwise, you simply use 2 functions with the name set and get (can be any name) as pointed out in the accepted answer.

My answer can also be interpreted as the question - Why do you need a property if you're not doing any validation on the value?
«_Superman_» 2-Sep-13 5:13am View
Use GetParent()->SendMessage(WM_XXX);
You would need to define your own custom message like this - #define WM_MYMESSAGE (WM_USER + 1)
«_Superman_» 21-Aug-13 1:03am View
Complicated problems have complicated solutions.
«_Superman_» 5-Aug-13 2:30am View
If this was possible, what's the point in a password.
«_Superman_» 19-Jul-13 3:29am View
Where did you get the CColorButton class.
It is not a standard MFC class.
So you must be asking this question to the author of CColorButton
«_Superman_» 20-May-13 23:38pm View
Your point in absolutely valid. 10 points for this.
However, it may not be applicable to this case because the destination in memset is tmp.get() and not &tmp.
Although I don't know how auto_ptr is implemented, the get method could return an address after the virtual pointer so that the vptr is not initialized to 0.

Also, I agree with others that this sort of initialization is not the right way to do it.
Another thing I would like to add here is that auto_ptr has been deprecated and should not be used. unique_ptr must be used instead.
«_Superman_» 19-May-13 22:14pm View
As mentioned in the solution below, add a WM_ERASEBKGND handler and return a non-zero value like TRUE.
This way you simple draw over the existing image instead of first erasing the existing image before drawing.
«_Superman_» 9-Mar-13 2:10am View
Where do you want to take it?
«_Superman_» 17-Jan-13 4:03am View
The lpszPassword parameter of LogonUser is optional.
So what happens if you initialize it to NULL?
«_Superman_» 12-Jan-13 5:55am View
They are correct, but incomplete. They do not have a member object.
«_Superman_» 12-Jan-13 5:52am View
You basically create an object of a class as a member of another class.
«_Superman_» 10-Jan-13 6:16am View
Open the root hub and use DeviceIoControl to send IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION.
«_Superman_» 29-Jul-12 10:00am View
Additional Info - The rule of union members not allowed to have explicitly defined constructors has changed in the latest C++ standard.
«_Superman_» 8-Jul-12 9:36am View
Add the code to the BN_CLICKED notification handler. You can add the handler for BN_CLICKED using the class wizard. If you're using an MFC project, simply double clicking on the button will create the handler for you.
«_Superman_» 21-Jun-12 2:47am View
Select the spin control in the dialog template and press F4 to go to the properties window. There you can see the said property called Set Buddy Integer. By default its value is False. You can change that to be True.
«_Superman_» 24-May-12 1:32am View
EMF files are made up of a header and individual records.
Each record is a GDI function.
What you need to look for is a textout function.
You can enumerate EMF records using the function EnumEnhMetaFile -
«_Superman_» 21-May-12 5:58am View
How do you build C.dll?
You should have a project in Visual Studio, right?
«_Superman_» 14-May-12 0:50am View
I use Visual Stdio and it compiles just fine.
No Error.
«_Superman_» 13-May-12 22:27pm View
The code as you've posted is fine.
Please post the code where the class template is being called.
«_Superman_» 22-Apr-12 23:24pm View
In that case, you need to do a lot more research.
Because you cannot rely on APIs like FindFirstFile as there are programs called rootkits that hide from such file enumerating APIs.
«_Superman_» 29-Mar-12 3:47am View
The CString class has an overloaded LPCTSTR operator which returns a const TCHAR*.
So the inner cast is an explicit call to this overloaded operator which we then cast to a LPTSTR which is nothing but a TCHAR*.
«_Superman_» 29-Mar-12 3:30am View
Try this - hmmio = mmioOpen((LPTSTR)(LPCTSTR)szFilename,NULL,MMIO_READ);
«_Superman_» 29-Mar-12 2:07am View
If you look carefully you will see that an & is missing in my post.
Are you sure PlaySound only works with small files. I'm not aware of this limitation. Please check with multiple files.
«_Superman_» 21-Mar-12 6:36am View
The batch file is also applying the system attribute.
So you need to apply the FILE_ATTRIBUTE_SYSTEM also.
«_Superman_» 21-Mar-12 5:45am View
The batch file simply does a rename followed by applying some attributes.
In Win32 you can achieve the same using the MoveFile API to rename a folder and the SetFileAttributes API to set the attributes on the folder.
«_Superman_» 20-Feb-12 8:57am View
You can use a custom allocator for the vector also.
«_Superman_» 7-Feb-12 0:39am View
Have you tried running the application with admin privileges like Christian said?
You can check if it works that way by right clicking on the executable and selecting Run as Administrator.
«_Superman_» 22-Jan-12 20:55pm View
You would need to subclass the edit control if you need to do this.
Look at SubclassDlgItem.
«_Superman_» 20-Jan-12 0:24am View
It could be a permission issue.
Try moving the DLL to another path like D:\Temp and try again.
«_Superman_» 19-Jan-12 2:40am View
Check if it works if you do a rebuild all.
Check this link -
«_Superman_» 19-Jan-12 1:37am View
Is that what you wish to do?
If so, right click on the MFC project in Solutions Explorer and select Add -> Existing Item and select the .C and .H files.
«_Superman_» 12-Jan-12 20:52pm View
Refer to this link -
«_Superman_» 12-Jan-12 0:04am View
It is very unlikely to get an answer here.
It would be best to post the question in the ALSA forums which I believe is this -
«_Superman_» 11-Jan-12 2:32am View
There are a few articles here on CP -
«_Superman_» 2-Dec-11 3:02am View
This will probably work in most situations, but it is possible to create a virtual printer where the port can be COM1 or USB1 in which case the port monitor will be customized.
«_Superman_» 25-Oct-11 7:12am View
This option is not useful for a DLL. The only use I can think of is an EXE querying this property to check if the DLL needs to be loaded elevated and then invoke a process with the necessary privileges.
«_Superman_» 16-Oct-11 22:40pm View
Although you can run 16-bit programs on 64-bit Intel x64 and AMD64 machines, 64-bit Windows does not support 16-bit programs. So you will not be able to directly run a 16-bit compiler on 64-bit Windows. However, as Mehdi Gholam stated in his answer, there is a program called DOSBox ( that you can use to run 16-bit programs. I have used DOSBox to run some 16-bit game programs on my 64-bit Windows machine.
«_Superman_» 22-Aug-11 19:07pm View
If you're talking of syntax, it is already perfect C++.
«_Superman_» 9-Aug-11 12:30pm View
You should add a comment to my reply and not post a new solution.
Anyway, to answer your question, you should take a look at IOCTL_INTERNAL_BTHENUM_GET_DEVINFO, although I have not done it myself.
«_Superman_» 28-Jul-11 19:45pm View
In VS 2010, you can either do as I replied or you can go to Tools -> Options -> Debugging -> Symbols and check the Microsoft Symbol Server option. You can now specify a folder in which you want the symbols to be stored.
«_Superman_» 17-Jul-11 9:25am View
«_Superman_» 9-May-11 3:16am View
The Microsoft compilers add these name decorations to distinguish between different calling conventions.
The __cdecl calling convention does not add this decoration.
If you want to export without using these decoration irrespective of the calling convention, you must export the functions using a DEF file instead of using __declspec(dllexport).
«_Superman_» 3-May-11 4:16am View
If you read the documentation properly, you can see that the number is actually a bit field where each bit represents a drive letter. You can check this as follows -
if (dwDrives & 1) A: exists.
if (dwDrives & 2) B: exists.
if (dwDrives & 4) C: exists.

You can get this in a for loop.
Try this -

for (int i = 0; i < 32; ++i)
if (dwDrives & (1 << i))
cout << 'A' + i << " exists\n";
«_Superman_» 25-Apr-11 22:09pm View
I think you're correct.
«_Superman_» 7-Apr-11 1:51am View
Forget about that function.
Just try this -
int rsIDVal = IDR_BUTTON1;
cout << rsIDVal;
«_Superman_» 6-Dec-10 14:17pm View
I do not have more information regarding this.
You could try a Java forum.
There is one on CP -
«_Superman_» 8-Nov-10 13:17pm View
Since you're creating the second class as a helper to the CSmartBlockDlg class, this is what I recommend.
Have the CEditData class constructor take a pointer to CSmartBlockDlg - CEditData(CSmartBlockDlg* pDlg);
Store this pointer in a member variable of CEditData - private: CSmartBlockDlg* m_pDlg;
Now in all methods of CEditData, whenever you invoking a function of the main dialog, use the m_pDlg-> syntax.

If you only want to have a CWnd* instead of CSmartBlockDlg*, you will not be able to call the functions directly. Instead you will have to define custom messages and then send or post these messages from the helper class.
«_Superman_» 7-Nov-10 22:42pm View
I did not mean for you to create new objects of these classes.
In your code you have created pointers which do not point to any object ,which is wrong.
You have to use the existing objects to call the functions.
Since both classes call each others methods, you will need to pass the object address of one class to another so that it can use it to call into the other class.
«_Superman_» 7-Nov-10 11:07am View
Here is what you're missing.
You have to create an object of a class (instantiate a class) before you can use it to call its methods.
You have only a declared a pointer and no memory has been allocated to it.
«_Superman_» 2-Nov-10 13:52pm View
You could simply put 4 instead of using sizeof and then typecasting it.
«_Superman_» 1-Nov-10 20:12pm View
I presume you want to show different text based on the selection.
For this you can change the text on the controls using SetWindowText.
To show entirely different control based on the selection, you could hide irrelevant controls and show relevant ones using ShowWindow.
You can also create controls dynamically using CreateWindow, but that is not recommended.
«_Superman_» 22-Oct-10 1:52am View
If you want to start another process from within your process you can use CreateProcess or ShellExecute or ShellExecuteEx or system.
«_Superman_» 20-Oct-10 5:50am View
Where does it fail?
Do you have error checking in place?
If an API fails, you could get more information by calling GetLastError();
«_Superman_» 28-Sep-10 8:15am View
You can either view the properties of the control in the dialog template editor and then set the Visible property to False.
Or you can call ShowWindow with SW_HIDE in the WM_INITDIALOG message handler.
«_Superman_» 28-Sep-10 3:02am View
To show/hide controls you can do GetDlgItem(IDC_CONTROL)->ShowWindow(SW_SHOW/SW_HIDE);
«_Superman_» 28-Aug-10 3:29am View
You can use other photo editing software like photoshop or gimp.
«_Superman_» 5-Jul-10 11:17am View
That's the beauty of the mp3 format.
You can cut it anywhere and it will play.
The format goes like this - .......
This is the reason you can have variable bit rates in mp3 files.
«_Superman_» 24-Jun-10 7:16am View
The documentation of EnterCriticalSection states that the owner thread can make additional calls without blocking.
But the documentation of CCriticalSection::Lock states that it is blocking.
I have not tried this myself.
Lock will not probably block on the same thread since CCriticalSection is a thin wrapper for CRITICAL_SECTION.
«_Superman_» 15-Jun-10 4:48am View
Take a look at this link -
«_Superman_» 14-Jun-10 4:44am View
Sure you can do this.
Just call LoadLibrary on the DLL from your application and then use GetProcAddress to get the address of the function to call.
If you want to share data between the POS and your application you can use shared segments or memory mapped files.
«_Superman_» 14-Jun-10 3:30am View
I still don't understand the problem completely.
So you have 1 DLL. Now do you have 1 EXE or 2 EXEs.

If you have only one, then you simply use LoadLibrary and GetProcAddress APIs from the EXE code to load and call the function in the DLL.
«_Superman_» 10-Jun-10 6:43am View
Remove the double quotes around the WM_XXX
«_Superman_» 3-Jun-10 1:09am View
Long term memory loss. :o)