|
Hello Guys,
I am too new to WIN32 programming. But knowing my fundamentals right in C,C++ i think the below 2 statements are absolutely fine:-
SOCKET m_socket;<br />
m_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );</
b>
SOCKET is a typdef of unsigned int
But when i compile this Win32 application it gives me an error on the second line that is the line:-
m_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
The error is that "error C2065: 'm_socket' : undeclared identifier"
I am unable to understand why this error, reading some other documents i tried to rectify this ERROR by adding the word SOCKET before M_socket, but then that means multiple declarations of the same variable, and i thought it would give an error but rather it gives a warning..
" warning C4101: 'm_socket' : unreferenced local variable' "
I dont know how to solve this.
Any help regarding this would be highly appreciated.
Thanks in advance,
Zalak Dedhia
Zalak Dedhia
|
|
|
|
|
Did you included the "Winsock2.h"?
|
|
|
|
|
Hey thanks eli15021979,
I had included the Winsock2.h
I got my mistake when i was reading my code carefully.
Thanks and Regards,
Zalak Dedhia
|
|
|
|
|
Hi Friends,
Please check following examples:
Example 1:
class Base1{
public:
int data0;
};
class Base2:public Base1{
public:
int data0;
};
class Derived: public Base2{
public:
int data0;
};
void main(void){
Derived D;
Base1 *bptr1= &D;
Base2 *bptr2=&D;
}
In above case :
Address of D=0x0012ff74;
Address of bptr1=0x0012ff74
Address of bptr2=0x0012ff74;
Now exmaple 2:
class Base1{
public:
int data0;
};
class Base2{
public:
int data0;
};
class Derived: public Base1,public Base2{
public:
int data0;
};
void main(void){
Derived D;
Base1 *bptr1= &D;
Base2 *bptr2=&D;
}
In above case :
Address of D=0x0012ff74;
Address of bptr1=0x0012ff74
Address of bptr2=0x0012ff78;
My question is why the base2 pointer has different address in above situation?
I have posted this long back but didn't get satisfied answer ..reposting...
VikramS
|
|
|
|
|
It is easier if you look at how the object is being built.
Base1: 4 bytes (for Base1::data0)
Base2: 4 bytes (for Base2::data0)
Derived: 12 bytes (for Base1::data0, Base2:data0, Derived::data0)
When you look at what is being allocated you see that object D is:
[[Base1::data0][Base2::data0][Derived::data0]]
So the address of:
- D is at offset 0.
- Base1 is at offset 0 because it is the first defined base class for Derived.
- Base2 is at offset 4, it adds to Derived by being tacked on after Base1.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I meant to say that
Why it different for Multiple Inheritance case only?
|
|
|
|
|
In the first example, since B2 inherits from B1, the address of B2 is the same as the address of B1.
Think of them as circles.
In example one, B1 is a circle. B2 inherits B1 so B2's circle encircles B1. D inherits from B2 so D encircles B2.
In example two, B1 is a circle. B2 is also a circle that doesn't encircle B1. D inherits from both B1 and B2 so D encircles both B1 and B2. However, since B1 and B2 can not exist at the same location in D, one of the two must follow the other. Thus B2 has a different address.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
In example two, B1 is a circle. B2 is also a circle that doesn't encircle B1. D inherits from both B1 and B2 so D encircles both B1 and B2. However, since B1 and B2 can not exist at the same location in D, one of the two must follow the other. Thus B2 has a different address.
Here as u say B1 & B2 does not exist on same location, same case is for normal inheritance too..why it needs special handling in MI only?
|
|
|
|
|
hi all,
I want to get rid of "Log on to Windows" Dialog in Windows 2000 Professional when starting windows.
How ever my computer is in a domain..
Can I pass user name and password to "Log on Dialog" using C++ when starting windows?
Thanks in advance..
|
|
|
|
|
pubududilena wrote:
I want to get rid of "Log on to Windows" Dialog in Windows 2000 Professional when starting windows.
This will require replacing MSGINA.DLL with one of your own.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hey, I was wondering if there was a way to prevent operator new() from calling the class constructor.
I have a CDialog derived class that creates a modeless dialog when it's constructor is called and I want to limit it to one instance. So what I want to do is when the dialog's operator new() is called, I want it to return a pointer to the already existing dialog. To accomplish this I have overridden the operator new() function
CWnd *CMyDialog::pMyDialog = NULL;
#ifdef _DEBUG
void CMyDialog::operator new(size_t Size, LPCSTR File, int Line)
{
if (pMyDialog)
return pMyDialog;
else
return CDialog::operator new(Size, File, Line)
}
#else
The problem is that once operator new() returns it immediately jumps to the class constructor, which initializes everthing to NULL, totally messing up the dialog that was created previously.
Now I know that I can keep a pointer for the dialog in it's parent window, and check that pointer to see if the dialog is active, but I want to try something different if it at all possible. This way the dialog can be created or accessed from any other class without having to have access to the stored pointer.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
why not make it a singleton?
|
|
|
|
|
Zdeslav Vojkovic wrote:
why not make it a singleton?
Because I did not know what that was until now
Thanks for the suggestion, seems to fit the bill perfectly.
Do you have a prefered method on how to do this? or are the articles present here on CP all equal in their implementation?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
when i display the shutdown dialog box(i did.). i want the procedure can select the item with shutdown/restart/logoff/... and does it's selection., how can i do ?
|
|
|
|
|
take a look at radiobuttons, GetCheck and ExitWindowsEx()
|
|
|
|
|
|
|
This code:
void Model3D::smooth() {<br />
vector<Vertex*>* newVertices = new vector<Vertex*>;<br />
float avg = 0.0f;<br />
for(int i=0; i<vertices->size(); i++) {<br />
Vertex *oldV = vertices->at(i);<br />
Vector3D pOld = Vector3D(oldV->x,oldV->y,oldV->z);<br />
Vector3D d = Vector3D(0.0f,0.0f,0.0f);<br />
int numOfVertices = 0;<br />
for(int j=0; j<oldV->edges->size(); j++) {<br />
Edge* e= edges->at(oldV->edges->at(j));<br />
Vertex* v= vertices->at(e->vertices->at(0));<br />
if(v->id == oldV->id)<br />
v= vertices->at(e->vertices->at(0));<br />
numOfVertices++;<br />
Vector3D qi = Vector3D(v->x,v->y,v->z);<br />
d = d + (qi-pOld);<br />
}<br />
d = d / (float)numOfVertices;<br />
d = d * ALPHA;<br />
avg += sqrt(d.x*d.x + d.y*d.y + d.z*d.z);<br />
Vector3D pNew = Vector3D(0.0f,0.0f,0.0f); <br />
pNew = pOld + d;<br />
Vertex *newV = new Vertex(oldV->id,pNew.x, pNew.y, pNew.z);<br />
newVertices->push_back(newV);<br />
}<br />
avg = avg / vertices->size();<br />
for(i=0; i<newVertices->size(); i++) {<br />
Vertex* v = vertices->at(i);<br />
Vector3D n = Vector3D(v->nx,v->ny,v->nz);<br />
n = n * avg;<br />
v->x = v->x + n.x;<br />
v->y = v->y + n.y;<br />
v->z = v->z + n.z;<br />
}<br />
for(i=0; i<vertices->size(); i++) {<br />
Vertex *oldV = vertices->at(i);<br />
Vertex *newV = newVertices->at(i);<br />
oldV->x = newV->x;<br />
oldV->y = newV->y;<br />
oldV->z = newV->z;<br />
delete newV;<br />
}<br />
}<br />
shows an incredible consumption of memory in the Win task manager when it is run several times over the same Model3D object... ideally NO memory should be used... can anyone help, please?
thanks,
FG
|
|
|
|
|
vector* newVertices = new vector;
you are not deleting this vector
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi,
Plz have a look at the following code snippet.This code will be executing in an endless while loop waiting for an event to be logged in the application log.If any event is logged then it will post a message to the dialog class for displaying it.
NotifyChangeEventLog(hEventLog, hEvent);
DWORD dwWaitResult = WaitForSingleObject(hEvent, INFINITE);
if(dwWaitResult ==WAIT_FAILED)
{
AfxMessageBox("Waiting Failed");
return 0;
}
PostMessage(pDlg->m_hWnd,UM_EVENT_LOGGED,0,0); //(long)hEventLog );
Now the problem is it will not notify all the events logged.ie if it notifyes a event logged then it will notifyes only after 5 seconds.So all the events logged with in this 5 second time will be lossed.
Plz help me with a solution...
With Luv
|
|
|
|
|
WaitForSingleObject is stopping your application for five seconds, until it times out, I reckon.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
"WaitForSingleObject" never get timed out becoz the time out parameter is specified as "INIFINITE".
Suppose if an event is logged at 12:05:30(hh:mm:ss).
If ur belief is true, then the application will displays the event only at
12:05:35. Isn't it?
But here it displays at 12:05:30 itself. But after that it is ignored all the events logging till 12:05:35.
|
|
|
|
|
VCSharp007 wrote:
if it notifyes a event logged then it will notifyes only after 5 seconds.So all the events logged with in this 5 second time will be lossed.
This is by design because the system calls PulseEvent() no more than once every five seconds.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
...any idea to overcome this problem?
any alternate method for checking the event logging process??
Plz tell me a solution.
|
|
|
|
|
Couple what you have with a "date/time since last check" flag.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|