inline make any difference ?
Does inline make any difference in my functions ?
I think it's auto generated from the editor if I put the function before the main() coz the C++ rule is to declaare the function which is not needed if I put it before main() ...
inline was made for this [if I'm not wrong] and for make access to function faster but ocuupie memory greater ...
If no need to it why it still exist as keyword ? My suggestion is don't let the editor generate it ; only when I need it I put it .
[517 byte] By [
Amahdy] at [2007-11-11 10:02:13]

# 1 Re: inline make any difference ?
Forced inline will make your program execute faster if the function is not invalid for inline (recrusive, etc) and if the function is appropriate to inline (sometimes, you can mess up and make the program SLOWER with inline). In general, unless you are in a real time system, your compiler should be set to inline at its own discretion. If you are SURE that this is a good place to inline, you can use __forceinline keyword on .net or a macro or a #include codefile to force inline for your situation.
jonnin at 2007-11-11 20:59:32 >

# 2 Re: inline make any difference ?
inline has nothing to do with the order of declarations/definitions. It was originallyu added to C++ in order to make setters and getters as efficient as direct member access. Today, it's less and less needed because compilers are much smarter than they were in the 80s. It's still in the language because there's always some compiler that might need this hint, and besides, there are so many other keywords that no one uses such as auto (when was the last time you saw THIS one used?) and register. Removing a keyword from the language would cause existing code to break, so it won't hapen so soon, if ever. As a rule, don't use what you don't need.
Danny at 2007-11-11 21:00:37 >

# 3 Re: inline make any difference ?
Yes Danny we nowadays ignore small [tens to zero] difference in the time and space between variables and here for inline , I remember in C we must check if the pointer hasn't passed memory limits if I assgine to it such a "string" ! but what's your idea about let the editor "not the compiler" decide wether auto putting it before compilation or not ?
My idea this method by MS VS 6.0 for example [which I use] isn't good , we aren't making vb application, we need sensevity and exactness ! I think they will continue making this in .net and finally we will get after many upgrades no difference between c and vb and # familly .
Amahdy at 2007-11-11 21:01:35 >

# 4 Re: inline make any difference ?
You mean that your IDE autimatically inserts inline to functions? That's bad. I think you can reconfigure it though. Notice also that any member function defined (i.e., implemented) inside the class body is automatically declared inline, whether that keyowrd is explictly used or not:
struct S
{
void func() {} //implicit inline
}
Danny at 2007-11-11 21:02:36 >

# 5 Re: inline make any difference ?
No I don't mean "insert" by a visible method , but internally when I heat "build" ...as I said before , literals like float too [in modern c++ editor try float a=2.6; it will accept it ]
About "struct" are u sure about this ? if so it will be great importance to use class and not structures in c projects or we will kill the memory with class objects .
it's useful to mention that in the question about difference between struct and class but please tell us the target .
Amahdy at 2007-11-11 21:03:40 >

# 6 Re: inline make any difference ?
The struct/class thing applies only to C++. C doesn't have classes so you can only use structs in C.
I still don't understand what's wrong with float a=2.6; Do you expect it to be double instead?
Danny at 2007-11-11 21:04:39 >

# 7 Re: inline make any difference ?
I'm sorry maybe I haven't good explained .
<No I don't mean "insert" by a visible method , but internally when I hit "build" >
I think this line is clear .
<literals like float too [in modern c++ editor try float a=2.6; it will accept it ]>
C++ literals are int "WORD" and double "DWORD" , it can't understand initialization of float for example . so we need to put "F" at the end to let it know I want to convert this init. to float "FLOAT m" ... now in modern editors u haven't to write this "F" it interly write it without mention that ... and don't insert it in the code . this why I'm talking about trying : "float a=2.6" which will not make errors and will not be edited visibly .
<it will be great importance to use class and not structures in c projects or we will kill the memory with class objects >
I mean c++ projects but I had writen c for fastness , and I mean if we use struct like class in the project it will kill the memory if as u said : "implicit inline" so I'm asking if u are sure about this coz this is a great benifit to use in "C++ big project" class not struct to save memory .
Finally I'm asking u to mention that in the thread asking about the difference between "class" and "struct" and tell us a target which mention this .
Amahdy at 2007-11-11 21:05:39 >

# 8 Re: inline make any difference ?
Yes, I'm sure about the implicit inline in member functions defined inside their class/struct. As for efficiency: there's absolutely no difference between structs and classes in C++. If you mean using structs with public data members instead of using accessor member functions, this is bad. It violates OOP principles and isn't necessarily more efficient than an inline get() or set() function.
As for lietaral: the F suffix indicates a float type. If you have a literal with a decimal point that doesn't have the f/F suffix, it's considered double, not float:
2.0; //double
2.0f; //float
DWORD and WORD are just typedefs, they're not real C++ types.
Danny at 2007-11-11 21:06:36 >

# 9 Re: inline make any difference ?
and this : "float x = 2.0;" double too ? I mean the editor auto correct this , it insert "F" but not visible .
anyway it's not important .. thank you and joninn for informations .
Amahdy at 2007-11-11 21:07:45 >

# 10 Re: inline make any difference ?
yes, it's double too (the literal, that is). The problem is that the double is silently converted to float when you assign it to x.
To override the automatic type deduction of double, add the suffix f/F to the literal, or better yet, change x's type to double. There's no reason to use float anyway.
Danny at 2007-11-11 21:08:47 >

# 11 Re: inline make any difference ?
I think compiler [abstract compiler] can't accept this , so it's not double , if your editor convert it to double it try to finds a method , but I know that most new editors insert "F" before pass it to compiler , so it will accept it "as float" if it was designed to fix from float input to it's internal representation .
Amahdy at 2007-11-11 21:09:45 >
