|
It usually is in the same order as you declare, but it's not required to by the C++ standard. In fact, the standard doesn't talk about object layout at all.
AFAIK, COM relies on the ordering of functions in the vtable, so I guess the VC++ compiler must put them in the same order as you declare.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
tis a crap question but i still would want to clear em.....
say that i have class say:
class xyz
{
int a;
public:
int return_value(void);
};
int xyz::return_value(void)
{
return(a);
}
as the above function is does not manipulate the data of the class,we can declare it also as ......
class xyz
{
int a;
public:
int return_value(void) const;
};
int xyz::return_value(void) const
{
return(a);
}
right?.....what i want to know iz iz there any other advantage of writing a 'const' after function that does not manipulate the data?.....
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
AFAIK, the 'advantage' of using a constant function is to protect member variable integrity from being modified. Obviously you would not use it everywhere, but for areas of your class that has functions that you know should be read-only, then this sort of safe-guards the class from unscrupulously changing data it shouldn't.
I Dream of Absolute Zero
|
|
|
|
|
It simply indicates to the caller that the method is "read-only" and does not modify the object for which it is called. It can also serve as a reminder to anyone that changes the class.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
DavidCrow wrote:
It simply indicates to the caller that the method is "read-only" and does not modify the object for which it is called. It can also serve as a reminder to anyone that changes the class.
...and prevent any modification on the object from within the function...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Yes, that's what "does not modify the object for which it is called" means.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
It doesn't "prevent" such modifications.
Just makes it more difficult and explicit (like using const_cast).
-----------------------------
Get trial copy of comment generating tool CommentMakerPro, a collection of convenience and productivity tools for Microsoft Visual Studio .NET FeinStuff, and std::string and std::string containers viewer FeinEvaluatorPro at www.FeinSoftware.com
|
|
|
|
|
I would REALLY appreciate if whoever voted my post down (not that I care about the "score") explained their position.
Vlad.
-----------------------------
Get trial copy of comment generating tool CommentMakerPro, a collection of convenience and productivity tools for Microsoft Visual Studio .NET FeinStuff, and std::string and std::string containers viewer FeinEvaluatorPro at www.FeinSoftware.com
|
|
|
|
|
The compiler will complain if you try to modify data from within the function. Also, if you declare your member functions const, that'll enable callers to call them from const functions..
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
S. Senthil Kumar wrote:
Also, if you declare your member functions const, that'll enable callers to call them from const functions.
...to call them from const objects.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
|
Hi,
Could anyone tell me how I could get GMT using COleDateTime? ::GetCurrentTime returns local time, right? But there is no function to get GMT (I can't use CTime, I have to use COleDateTime).
Thanks!
|
|
|
|
|
How about:
SYSTEMTIME st;
GetSystemTime(&st);
COleDateTime utc(st);
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Excellent, thank you very much!
|
|
|
|
|
Hello everyone!
I have a project based on Property Wizard Component which have four propertypages .
Now i am trying to make them displayed as maximum/minimum size when they come out to the user.
At first i tried to use SendMessage(WM_SYSCOMMAND,SC_MAXIMUM,NULL) in the initdialog() of my proppage,but it seems there is no respone to the message .
and i found that it appears no response although i have tick on the maximize/minimize box in the styles of the dialog property.
i don't know what to do now .I wonder if there is anyone can help me
ThanX in advance!!!!!!!!!!!!!
|
|
|
|
|
By design, the initial size of the sheet is governed by the size of the largest page.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello sir,
thanx for your reply!
Do you mean that we can not resize or maximize/minimize our properpage in our Wizard ? i do not think so, there are quite a lot of articles just in codeproject teach us how to resize them,so i think we can maximize them,but i don not know how toooooooo
|
|
|
|
|
Now i see how to solve that ,just use SendMessage(WM_SYSCOMMAND,SC_MAXIMIZE,NULL) in the initdialog() of CPropertySheet.
ThanX Again,sir!!!!!!!!!!
|
|
|
|
|
steven_wong wrote:
Do you mean that we can not resize or maximize/minimize our properpage in our Wizard ? i do not think so
Per MSDN:
PropertySheet automatically sets the size and initial position of a property sheet. The position is based on the position of the owner window, and the size is based on the largest page specified in the array of pages when the property sheet was created.
steven_wong wrote:
there are quite a lot of articles just in codeproject teach us how to resize them...but i don not know how toooooooo
So why not just consult those articles to find out how?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello guys!
Anybody here knows the maximum allowable length of the Standard C++ string class?
Thanks!
|
|
|
|
|
As much as memory allows!
I Dream of Absolute Zero
|
|
|
|
|
don't really know, but maybe having a look at the indexes type will let you gess the max of items allowed...
physically, you will certainly be limited before you reach the logical limit of the string...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Have a look at basic_string::max_size() . I think that STL does not have a maximum length requirement, thus the reason why max_size() is a function and not a normal data member or a constant.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Thank you for your help.
Do you guys know where to get a detailed documentation on basic_string's max_size() function?
MSDN library does not elaborate on this... it only include a sample function.
I really need to support my solution.
Thanks a million!
|
|
|
|
|
Hello,
I am trying to use the windows serial port driver using VC++(MFC). I need to work with 76800 baud. But the function "SetCommState" is returning error "Parameter incorrect" when i fill DCB struct with 76800 baud.
Can any one please help in this regard.
I have downloaded serial classes from net, but My requirement is not working.
Thanks in advance
sivack
|
|
|
|