|
In fact the rule is really simple: you can merely put 'almost' what you want. Preprocess is in fact far less complicated that you might think, it is really no more than text processing. In this case, the #define TEggCodeParser_Class can be used later as a kind of flag: if you check for the existance of TEggCodeParser_Class , you can remove certain part of your code from the compilation.
The second example is used to avoid including multiple time the same header file. Don't forget that both of these conditions should be terminated by a #endif. If EXAMPLE_H was already defined (because the header file was already included for example), then everything which lies between the #if !defined and the #endif will be 'discarded'.
|
|
|
|
|
Hello,
I had set timeout with
int n = 20000;
setsockopt(ClientSocket,SOL_SOCKET,SO_RCVTIMEO,(char*)&n,sizeof(int);
and
set mode nonblocking with function call
int iMode = 1;
ioctlsocket(ClientSocket,FIONBIO,(u_long FAR*)&iMode)
if i set mode to nonblocking than timeout is not called in recv().
but if i do it with mode blocking (default) than every thing is
working fine and timeout called.but i have to work with non blocking
mode so anybody can tell me how can i set timeout in nonblocking socket.
or why i dont get timeout ,i missed something plz reply.
Thanx in advance. 
|
|
|
|
|
one Suggestion re posting questions will not help you to get answers.
Now i am not sure if this will answer the problem but i will try.
1. Blocking socket and time out set.
This is ideal condition since it is a blocking call After timeout it will come out of the blocking call if nothing to receive.
2. Non blocking and time out set.
Since this is the non blocking call it will come out immediately so there is no need of timeout rather even if it is set you will not get it because if there is nothing to receive call will return..
I hope that makes sense.
Regards,
Sandip.
|
|
|
|
|
Hi,
I have a very famous problem with multiple inheritance here.
class A{
public:
A(){ cout<<"A"<<endl; }
};
class B: public A{
public:
B(){ cout<<"B"<<endl; }
};
class C: public A{
public:
C(){ cout<<"C"<<endl; }
};
class D:public B,public C{
public:
D(){ cout<<"D"<<endl; }
};
int main()
{
D *d = new D;
}
Output:
A
B
A
C
D
I am not able to understand that why the constructor of A is called again after B. Or why not the same is happening after constructor of C is called.
|
|
|
|
|
laksh2204 wrote: I am not able to understand that why the constructor of A is called again after B. Or why not the same is happening after constructor of C is called.
So the compiler goes likes this...
First time it sees "new D" it
1. calls constructor of D
2. which in turn calls constructor of B (Since B if the first base class)
3. which in turn calls constructor of A (Prints "A")
4. then (Prints "B")
5. then the compiler calls constructor of C (Second base class)
6. which in turn again calls constructor of A (Prints "A")
7. then (Prints "C")
8. in the end (Prints "D")
So bottom line is unless base class constructor code executes derived class
constructor doesn't execute.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
modified on Wednesday, August 27, 2008 8:58 AM
|
|
|
|
|
OK, thats nice explanation..
one more issue comes into my mind.
A
/ \
B C
\ /
D
In the same diamond structure if my declaration is like:
class A;
class B : virtual public A;
class C : virtual public A;
class D : public B, public C;
now when i do
A *d = new D; //it will work as ambiguity is removed by virtual.
But, which path will be followed??
A->B->D or A->C->D??
or something else...
|
|
|
|
|
laksh2204 wrote: A *d = new D; //it will work as ambiguity is removed by virtual.
But, which path will be followed??
A->B->D or A->C->D??
Now your output will be
A
B
C
D
I guess first base class gets the preference.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
This is due to the fact that the base class constructor has to get called before the derived class constructor gets call. since D derives from both B and C constructor of A gets called in either of the cases
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
Hi Friends,
I want to run a VB Script in a button click event.
This VB Script is defined in the program itself.
Could anyone tell me how to run the script.
The price of anything is the amount of life you exchange for it.
Thanks and Regards.
SANTHOSH V
|
|
|
|
|
|
Hi All
Can i add EditControl through code.if yes then plz help me..
|
|
|
|
|
|
Thx's it is working..Can i show new edit as a visible false..
|
|
|
|
|
MsmVc wrote: Can i show new edit as a visible false
|
|
|
|
|
MsmVc wrote: Can i show new edit as a visible false..
No. Setting the Visible property to false means you want the window to be hidden, not shown. Now, are you wanting to show or hide the window? Perhaps the removal or inclusion of the WS_VISIBLE style is what you are after.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
OR you can use of ShowWindow(SW_HIDE).
|
|
|
|
|
This link[^] seems helpful.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Or you can use of CreateWindow.
|
|
|
|
|
How can i add variable of edit control when i am useing this one
void CMyView::OnInitialUpdate() <br />
{<br />
CView::OnInitialUpdate();<br />
<br />
CEdit* pEdit = new CEdit;<br />
pEdit->Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,<br />
CRect(10, 10, 100, 100), this, 1);<br />
}
Plz help me
|
|
|
|
|
|
Of course you must be declare your variable outside of a function.
|
|
|
|
|
Hi all!
I have the following class and i want a way to make the tree, and edit controls to have access to MAINCLASS variables.
a. Is that OK to create a constructor to each one of the controls to pass a parameter something like
Window* wn;
And use it as ((MAINCLASS *)mainwindow)->a; within class implementation ?
Or can you suggest me an other OOP way because i have read somewhere that this way to convert a base class object (mainwindow) to a derived class object is not so legal?
class MAINCLASS: public window
{
...
...
public:
//constructor
//destructor
MyTreeCtrl tc;
MyEditCtrl ec;
...
...
public:
// Variables
int a;
}
a.
// in MyTreeCtrl h
class MyTreeCtrl
{
...
...
public:
MyTreeCtrl(Window* wn)
void Foo();
...
...
public:
// Variables
Window *mainwindow;
};
// in MyTreeCtrl cpp
MyTreeCtrl::MyTreeCtrl(Window* wn)
{
mainwindow = wn;
}
MyTreeCtrl::void Foo()
{
...
int b = ((MAINCLASS *)mainwindow)->;a
...
}
Thanks!
|
|
|
|
|
one suggestion (Off Topic) : Please use code block tags for posting code. Also indent the code so it is readable.
Now about the topic.
You can use forward declaration to solve your problem.
Check this link for example : Forward declaration[^]
Regards,
Sandip.
|
|
|
|
|
Hi All
I want to set OS directory in editbox.i want to set OS directory name when my application is run.Plz help me
|
|
|
|