|
MR kuphryn Firstly I know it because I have a network traffic sniffer running on the detinaion of the program so when packet will reach it will show it.
Second I am not using the datagram socket sock_dgram but creating the tcp packet
socket(AF_INET, SOCK_RAW, IPPROTO_RAW)
IP.PROTOCOL =IPPROTO_TCP
using raw socket please if you can help me by any reference any helping material, code , or anything please do me a favour.
Reply me soon
|
|
|
|
|
According to the rules of C++, a constructor for a class taking a single parameter, could be used to implicitly convert the value of the constructor's parameter type to a value of the constructor's class type.
That means, I ought to be able to convert an "int" value, to a "Number" value. That is not happening. Can anybody see why?
Thanks!
====================================
class Acct;
class Number
{
public:
Number(int i=0) : n(i) {}
Number(const Acct& ac) : acct(ac) {}
void print(Number nbr) { cout<< " Nbr: " << nbr <<endl; }
private:
Acct acct;
int n;
};
----------------------------------------------
int main()
{
Number num;
num.print(99);
return 0;
}
========================
Because it's an "int" I'm printing (as a result of the conversion), I should be able to use the regular standard I/O operators to output the result. The compiler doesn't believe so, and is complaining about that too.
William
Fortes in fide et opere!
|
|
|
|
|
William,
The conversion from int to Number is legitimate in C++, and my VC++ 6.0 compiles it fine. But the print function wont compile, since you are printing a 'Number' and not an int.The compiler has no idea about printing the Number type.To do this you need to overload the insertion operator "<<".
~ Vimal
|
|
|
|
|
Thanks Vimal.
You make a lot of sense and you are correct. However, I had done just what you recommended before posting the note, and everything did work for me.
But when examined, overloading the stream insertion operator "<<" didn't looked like it bought me anything, because I could have obtained the same result if I had not used constructor conversion and had done things the regular way, using an "int" instead for my print() parameter.
I figured as part of the ctor conversion technique, one of the benefits I would obtain, would be NOT having to overload the "<<" operator. Secondly (and this is the part that made me refused to give up), I thought somebody might know of a way (that I didn't) to make what I was trying to achieve, work.
I thank you for your response because it tells me what I was dreaming of doing, will just not work.
Thanks again!
William
Fortes in fide et opere!
|
|
|
|
|
Try changing the print to take a reference:
void print (Number &nbr)
|
|
|
|
|
Friends, i am doing something like:
using namespace std;
hash_set<string> myhashstring;
myhashstring.insert("USA");
As such program is giving me error that:
(38): error C2440: 'type cast' : cannot convert from 'const std::string' to 'size_t'
But if i use "set" instead of "hash_set" the program works normally. Any one guess whats the problem ???
|
|
|
|
|
hash_set is a container. In your code, you did not include the correct template parameters.
http://www.sgi.com/tech/stl/hash_set.html
Kuphryn
|
|
|
|
|
I try to make a CComboBox dynamically which have owner draw.
first, I tried it myself.
It compiled ok, but "Unhandled Access Violation" when execute.
So, I find exercises about ComboBox which have owner draw in CodeProject and Codeguru.
Though So many exercies are, they are not dynamically, but static in dialog
How can I Create CComboBox dynamically which have owner draw?
to be Ace.
|
|
|
|
|
Kindly tell what is a #pragma and why is it a must to use it at some places
Gaurav Gumber
|
|
|
|
|
#pragma gives commands to the compiler. The ones I commonly use are pack to change how struct members are arranged in memory, and comment(lib) to make the linker use a particular import LIB file.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
I would like to achive the following:
91.26464 --> 91.26 (2 digits after the floating point at most)
91.20464 --> 91.2 (because of the 0 at the second position)
91.00464 --> 91 (first 2 digits sfter the floating point are 00)
I tried to use setpresicion and setiosflags but it seems I don't know how to get these results.
-----------------------
Go USA Go
|
|
|
|
|
I have a vexing problem related to CListCtrls and in-place edit.
Very standard stuff here, the CListCtrl is on CPropertyPage.
Inplace editing is called for 4 SubItems/Columns and works perfectly however when
SubItems greater than 0 are dblClicked (i.e list.EditLabel() & OnBeginLabelEdit) the ListItem in column 0 becomes blank until editing is complete (i.e OnEndLabelEdit) when all is restored and OK.
Somehow the SubClassed EditCtrl Overwrites the list.Item before being repositioned over SubItem?
DWORD dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_CHILDRES
WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP | LVS_EDITLABELS ;
DWORD dwEXStyle = LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | WS_EX_CLIENTEDGE;
======OnBeginLabelEdit Handler========
CRect rc;
c_List.GetSubItemRect(iItem, iSubItem, LVIR_LABEL, rc );
HWND hWnd = (HWND)c_List.SendMessage(LVM_GETEDITCONTROL);
ASSERT(hWnd != NULL);
VERIFY(m_SubClassedCEdit.SubclassWindow(hWnd));
ASSERT(::IsWindow(m_SubClassedCEdit.m_hWnd));
m_SubClassedCEdit.m_Rec = rc;
m_SubClassedCEdit.SetWindowText(c_List.GetItemText(iItem, iSubItem));
=========================
It must be obvious but I cannot see it. I have tried Invalidating the item, the list ...?$#
Anyone have a working example of item/subitem in-place edit of CListCtrl?
If there are any kind souls out there - please help
Regards In Advance
Bonnie
|
|
|
|
|
While I was looking at an example of class operations I saw something I never seen before. Where the constructor for class Position is declared there is a “:x(xx),y(yy)” statement and I can’t understand what it is doing. I seems like it is using float x and y as functions, and this even before the “{}”. Please explain this statement, what it does, how it does it, what else strange statements like this you can do and if there is any where I can read more about this?
#include<iostream.h><br />
<br />
class Position {<br />
float x,y;<br />
public:<br />
Position(float xx, float yy=0):x(xx),y(yy) {}<br />
Position operator + (const Position& e) const;<br />
Position operator - (const Position& e) const;<br />
<br />
void Display(void)<br />
{ cout << "(" << x << ", " << y << ")" << endl; }<br />
void Input(void)<br />
{ cout << "enter x och y:"; cin >> y;; }<br />
};<br />
<br />
Position Position::operator + (const Position& e) const<br />
{<br />
Position res = *this;<br />
res.x += e.x;<br />
res.y += e.y;<br />
return (res);<br />
}<br />
<br />
Position Position::operator - (const Position& e) const<br />
{<br />
Position res = *this;<br />
res.x -= e.x;<br />
res.y -= e.y;<br />
return (res);<br />
}
Aidman » over and out
|
|
|
|
|
|
Hi,
I've overide a WM_KEY and WM_GETDLGCODE of an CEdit to know when the user presse "enter" key like this :
UINT CMyEdit::OnGetDlgCode()
{
return DLGC_WANTALLKEYS;
}
void CMyEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar==0x0000000d)
Funtion();
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
this way, i can call Function() when user press "enter"... Unfortunalty, there is a "bip" (sound system) when the "enter" key is pressed...
Does anyone know how to disable this "bip" ??
Thanks yyou veru much
|
|
|
|
|
I am writing a C++ DLL which will be called by Visual Basic for Applications in Excel. Should I be using BOOL vs. bool as the type of arguments passed to/from the DLL. For some reason bool doesn't work ... Both C++'s true and false are interpreted as True in VB. Does anyone know why?
Is bool just a 1-byte character whereas BOOL is like an int? What is Boolean type in VB equivalent to in C++?
|
|
|
|
|
Anton A. Loukine wrote:
Should I be using BOOL vs. bool
BOOL
and tell the VB users to use a Long on their end.
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
So BOOL is a 32-bit integer?
|
|
|
|
|
Anton A. Loukine wrote:
So BOOL is a 32-bit integer?
yep.
it's #define'd as int or long, depending on which set of #include files you happen to pick up. but they're both 32 bits in Win32.
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
You should be using VARIANT_BOOL , which is a 2-byte type and the VB/VBA version of a boolean. Use the two constants VARIANT_TRUE and VARIANT_FALSE for the values.
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
I am currently trying to perform a mathematical addition on two strings. I was curious if there were any built-in functions available for this. If not that is okay. Thx for any help.
|
|
|
|
|
Hi,
I've written a small application, very basic, that works on Windows Me, Windows XP and Windows 2000, but (I am told) crashes with the error "abnormal program termination" in Windows 98. The program uses the common control progress bar (and uses Initcommoncontrolsex etc to set it up), a ZipArchive library, and not really much more. I can't see why I might be getting this error.
I'm a fairly inexperienced programmer, so if somebody could tell me where I might start looking (the types of things I need to look at) in my program, or the general things that might cause a crash on Win98 where it works on other systems, I would be really grateful.
Thank you,
Keith B.
|
|
|
|
|
First check if it crashes on more than one Win98 system. The problem may be related to the user's PC which just happens to run Win98, and not Win98 itself. I'd look for missing files that the program expects to find. It's possible that you may not have adequate error recovery in your code.
For example, stuff like this is dangerous:
FILE* fp = fopen ("C:\\file.dat");
char szLine [256];
fgets (szLine, 255, fp);
fclose (fp);
It's safer to do:
FILE* fp = fopen ("C:\\file.dat");
if (fp == NULL)
displayError();
else {
char szLine [256];
fgets (szLine, 255, fp);
fclose (fp);
}
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi,
Thanks for the reply. I have done as you suggested and added a lot more error checks, and sent the executable out for more testing (hopefully it will at least spew up a more helpful error message that way, thanks for the suggestion). I still don't understand it, though, as I've tested it on a Windows 95 system and it works fine. I can't quite understand why it would work on Windows 95 and Windows Me, but not on Windows 98 - and a couple of Win98 systems have been tested, so it seems that it's not just the user's PC...
Many thanks,
Keith
|
|
|
|
|
Keith, the problem may be with Zip library you're using. Check the vendor's site (assuming it's a commercial product) for release notes regarding Win98.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|