Re: Templates and Non-Inline Functions
- From: "AliR" <AliR@xxxxxxxxxxxxx>
- Date: Tue, 7 Mar 2006 10:06:00 -0600
Yes you did. SomethingElse is not marked as inline and the body is not
within the class definition, so it's not going to be inlined.
AliR.
"Jonathan Wood" <jwood@xxxxxxxxxxxxxxxx> wrote in message
news:ON9JieYQGHA.2436@xxxxxxxxxxxxxxxxxxxxxxx
AliR,them
Ok here is the deal, when defining a class template. The implementation
has
to be in the .h file, because when there is a decleration the compiler
needs
both the definition and the decleration at the same time. Now that
explains
why you need to have everything in the h file.
Right, I understood that part.
Now as far as inlined template functions. It's up to you if you want
inlined or not
template<class T>
class MyTemp
{
int GetSomething(...) { reutrn something; } <---- inlined
int GetSomethingElse();
};
//not inlined
template<class T>
int MyTemp<T>::GetSomethingElse(...)
{
return somethingelse;
}
It this doesn't help you might want to ask the C++ experts at
comp.lang.c++ newsgroup.
So even if the above implementation of GetSomethingElse() appears in the
header file, it won't be an inline function because the implementation is
not defined within the class definition. Did I understand correctly?
Thanks.
--
Jonathan Wood
SoftCircuits
http://www.softcircuits.com
.
- Follow-Ups:
- Re: Templates and Non-Inline Functions
- From: Bo Persson
- Re: Templates and Non-Inline Functions
- References:
- Templates and Non-Inline Functions
- From: Jonathan Wood
- Re: Templates and Non-Inline Functions
- From: Jonathan Wood
- Re: Templates and Non-Inline Functions
- From: AliR
- Re: Templates and Non-Inline Functions
- From: Jonathan Wood
- Re: Templates and Non-Inline Functions
- From: AliR
- Re: Templates and Non-Inline Functions
- From: Jonathan Wood
- Templates and Non-Inline Functions
- Prev by Date: Re: Visual Studio.NET 2003 building woes .... :S
- Next by Date: Re: Using VC7.1 compiler under VC6 IDE.... woes.... :S
- Previous by thread: Re: Templates and Non-Inline Functions
- Next by thread: Re: Templates and Non-Inline Functions
- Index(es):
Relevant Pages
|