|
"For this reason, I suspect the most useful way to use static functions is for methods to initialise pointers of the class in question."
- Since I am a newbie, I do not understand your meaning.
- Can you give me an example to show the most useful way to use static functions as you mentioned?
Probably no example better than the one I gave. In GDI+ the Bitmap class has a method called FromFile and it's static, which means I can start with a Bitmap *, which has not had new called on it yet, and then call the static method, which is a bit like a global function which returns a Bitmap * when given a filename, but being a static function it exists in the namespace of the class. So given that you'll only have one instance of the function AND the function does not require you to have created an instance of the class, a sensible use for them would be to call a function that creates an instance of the class and returns it. I'm sure there are other uses, I use a static function to do a reference count for example.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
- Thanks, Christian pal!
- Your reply clarifies my doubts. And I still have a stupid question.
- For example, I use a static function named F1 in class A. Can I use the function F1 in another class B without creating an object (or pointer) of class A in class B. ( Suppose class B has no derivation relationship with class A)
- Can you help?
- Regards,
Maer
|
|
|
|
|
In that case it becomes a question of the relationship between A and B. If the function is public or B is a friend of A then that would not be a problem.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
- Thanks, Christian pal!
- You have clarified my doubts.
- Regards,
Maer
|
|
|
|
|
- Sorry for interrupting again pal!
- I can not find the "FromFile" function. (MSDN-->CBitMap-->class menbers-->)
- Can you help?
- Regards,
Maer
|
|
|
|
|
It's a GDI+ function in the Bitmap class, not a GDI function in the CBItmap class. If you don't have the SDK installed, you won't have access to it, but it's covered in the MSDN.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
- What is the difference between the following two sentences?
- const static enum { s = 20 };
- const static s = 20;
- Can you show me an example?
- Regards,
Maer
|
|
|
|
|
The first one creates an unnamed enum type, and defines the constant s to have the value 20. I don't know if the const has any effect there since enum values are by definition constants.
The second is a syntax error. It's almost a variable declaration - it's just missing the type. If it were static const int s=20; then it declares a int variable called s , with value 20 that can't be changed (const ) and is visible only in that .CPP file (static ).
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
Mike,
The second case is technically not a syntax error since the compiler assumes the default "int" type for the variable. Still, it's bad form and should not be used.
Regards,
Alvaro
|
|
|
|
|
- Thanks, Mike pal!
- I still have a question. What means "by definition constants" in your reply?
- Can you show me an example?
- Regards,
Maer
|
|
|
|
|
- What does the following sentence mean?
- Variable is a constant the compiler knows the value at compile time.
- Can you show me an example?
- Regards,
Maer
|
|
|
|
|
couldn't it be the other way round:
constant is a variable the compiler knows the value at compile time.. makes much more sense for me...
bernhard
""Politicians and diapers have one thing in common. They should both be changed regularly and for the same reason."
|
|
|
|
|
- Take a look at the following program:
#include<iostream>
using namespace std;
class a{
private:
static const int s ;
int i[s];
};
const int a:: s=20;
void main()
{ cout<
|
|
|
|
|
Variable is a constant the compiler knows the value at compile time
Are you talking about const variables?
Nish
Sonork ID 100.9786 voidmain
|
|
|
|
|
- I am talking about ordinary variables.
- Regards,
Maer
|
|
|
|
|
- Where did this sentence come from?
- It probably means that since the variable is declared "const", the compiler will know its exact value while it's compiling the file(s) that use it. Thus it can reliably use the variable for such things as allocating memory for arrays.
- Example:
const int MAX_ITEMS = 20;
Item items[MAX_ITEMS];
- Regards,
Alvaro
|
|
|
|
|
- Thanks, Alvaro pal!
- Take a look at the following program:
#include<iostream>
using namespace std;
class a{
private:
static const int s ;
int i[s];
};
const int a:: s=20;
void main()
{ cout<
|
|
|
|
|
- Thanks, Alvaro pal!
- Take a look at the following program:
#include
using namespace std;
class a{
private:
static const int s ;
int i[s];
};
const int a:: s=20;
void main()
{ cout<
|
|
|
|
|
Is this at all possible? I cannot use MFC or anything like that.
|
|
|
|
|
SetConsoleTextAttribute
Nish
Sonork ID 100.9786 voidmain
|
|
|
|
|
For a CPropertySheet, I can add a page in the constructor by typing AddPage. I can remove a page in the destructor by typing RemovePage. I read a comment from someone that said you can only call AddPage in the constructor. Is it possible to add and remove pages from a CPropertySheet dynamically? Is it possible/okay to add a button called Add Pages where they click on it and pages are added? Any thoughts?
Any response any one can give me will be greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Uou can definitely call 'Addpage' and 'RemovePage' at anytime - we have done this in a number of PopertySheet based dialogs (both normal and wizard mode)
-----------------------------
"I leave no turn un-stoned.
" - John Simmons, Nov 6 2001
-----------------------------
|
|
|
|
|
Yes, you can do that. Additionally, you may send the
PSM_RECALCPAGESIZES to the property sheet when you add/remove pages. You'll find more info about the message in MSDN.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hey Guys
I need a way to put a program into the start up procedure so when windows boots up next time it starts this program.
Any Ideas
Cheers
Peter
|
|
|
|
|
If you're running NT/2000/XP, you'll need to make it a service. For Win9x/ME, you could add it to the "Run" key in the registry or place a shortcut to it in the Startup folder.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|