|
Yes, for example if class1 and class2 are both declared in the same file and class1 is declared before class2. Othwrwise, it depends on what you mean by "use". Next time try a bit more descriptive subject if you post a question, please, "hi" just won't do...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
Hi back,
You can refer to a class that hasn't been defined (in simple terms not had it's .h included) but you can't do anything that requires the compiler to know the size or composition of the class. So, without the .h file you can...
- declare a reference to an object of the class
- declare a pointer to an object of the class
- assign pointer to objects of the class
You'd be pushed to say that this lot is "using" the class though. What you can't do...
- call member functions of the class
- do any sort of RTTI (run time type information)
- get the size of the class which in turn means you can't create objects of the class
Cheers,
Ash
|
|
|
|
|
|
Hello,
I have a small DLL written in C++ that exports 4 functions. I call this DLL from my C# application and can call all these functions without any problem.
I want to arrange for a DLL function to be called exactly once (sort of like a static constructor for the DLL). What is the best way to do something like this?
Thanks,
Keith
|
|
|
|
|
What do you mean by "called exactly once"?
You wanna prevent from "calling the dll function for a second time", or just make no
effect when "calling the dll function for a second time"?
|
|
|
|
|
You could try sticking the code you want executed exactly once in the DllMain for the DLL. Unfortunately there are some restrictions as to what can go in DllMain - don't do anything that might trigger another DLL load or it could go horribly wrong.
Another option is to create an initialisation function and either just call it once or use a language feature of C# to make sure it's only called once. I don't know C# and it's idioms enough to suggest a relevant feature. You can make sure your initialisation function is only called once in the DLL using something like:
extern "C"
bool FOO_EXPORT initialise_foo_lib()
try
{
static bool initialised = false;
if( !initialised )
{
initialised = true;
}
return initialised;
}
catch( std::exception & )
{
return false;
}
Cheers,
Ash
|
|
|
|
|
Hi,
would anyone if I can get Crect structure/CLass from the current selection
I would like to create Rgn to paint the Background of a bitmap displayed on my Richeditctrl
thankx
|
|
|
|
|
I'm assuming you're using MFC.
The CRichEditCtrl class has a method called GetSel which returns the index to the starting and ending characters in the selection.
Now use CRichEditCtrl::PosFromChar on the starting and ending characters to get their X and Y positions.
You can now build a CRect using the 2 CPoint structures returned.
|
|
|
|
|
Thankx
To create a region then to fill the background, I am going to try it, but I think I'll have to do ClienttoScreen afterwards since the regions is a area of the display
|
|
|
|
|
|
Thanx I going to try Supermans method
to fill the background then yours
thankx again
|
|
|
|
|
Hello,
I need to know about good C++ Reflection API(Would be better if Microsoft API is available) which enables me to determine the types(classes,structs,enums,ints,float,doubles...)identification at run time, declaring them and finally to call methods on those types at run time too.
Regards
Usman
|
|
|
|
|
Don't think that exists for C++.
see lengthy discussion on stackoverflow[^]
Watched code never compiles.
|
|
|
|
|
There isn't a good one - if you want to do Java style "create from arbitrary string" or "call method by string" then you won't be able to do it generally. If you're only interested in a subset of classes that you want to handle like that then have a look at the factory and abstract factory patterns, they might be enough for what you want, as might be COM (create an object by name, see if that object supports a particular interface) or CORBA.
Cheers,
Ash
|
|
|
|
|
Go managed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Sorry ,but C++ types runtime information is very limited.You could only get C++ clas instance type like this sample but calling a methods at runtime is not possible in general.
Life is a stage and we are all actors!
|
|
|
|
|
As other said before, this is not possible to do in C++. However, if you explain what exact situation you are trying to handle we might be able to suggest you an appropriate solution.
|
|
|
|
|
May be this is not what you want, but qt c++ framework do that.
|
|
|
|
|
Hi, is there any technics (owner draw class, function, subclass method and so on) to change backgroud color of datetimecontrol
Thank you
viliam
|
|
|
|
|
Check out the WM_CTLCOLOR , and related, messages.
If that does not work, you might look at the DTM_SETMCCOLOR message. Or, subclass the control and handle the WM_ERASEBKGND and WM_PAINT messages.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
WM_CONTROL is not called for this type of control
viliam
|
|
|
|
|
viliam wrote: WM_CONTROL is not called for this type of control
I've not ever heard of that message. Is it new?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Sorry, my typing error. I should be WM_CTLCOLOR
viliam
|
|
|
|
|
viliam wrote: Sorry, my typing error.
Don't "type" your code here. Please copy and paste!
Workout progress:
Current arm size: 14.4in
Desired arm size: 18in
Next Target: 15.4in by Dec 2010
Current training method: HIT
|
|
|
|
|
Hi,
Does anyone know how to load a map of maps? I've declared the map of maps as follows:
map<double,map<double,double>> a;
As a simple example, I'd like to load the following (in reality I'll be loading this format for nearly 500,000 entries):
0.0 1.57 2.65
0.5 0.00 3.21
1.0 6.52 0.00
1.5 0.17 4.54
The first column is the key (it is time in seconds).
Thanks,
|
|
|
|