|
|
thx for reply. i created own one "component" yesterday.
there was a lot of routine coding, thats why i was looking for some example code.
wbr
|
|
|
|
|
I am using Visual Studios 2005 version v8.0 (.NET framework v2.0)
Hi Getting at error about _TEMPLATE_MEMBER
typedef typename allocator<T>::_TEMPLATE_MEMBER rebind<T>::other _Alloc;
I think it's something to do with _TEMPLATE_MEMBER and it only being know in ealier versions of visual sudios
Anybody know anything about it???????????????
|
|
|
|
|
Hello,
Is there a simple statement to hide the mouse pointer?
thanks
Simon
|
|
|
|
|
simon alec smith wrote: Is there a simple statement to hide the mouse pointer?
::ShowCursor(FALSE);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Hi
How chanhe frame color style using CWnd::CreateEx ?
Thanks
|
|
|
|
|
You can draw the frame yourself in response to the WM_NCPAINT
message.
Maybe some info here to get you started:
Guide to WIN32 Paint for Intermediates[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everyone,
For C++ template, it will be expanded at compile time other than runtime. So, I think in the code below for line "Abc<Foo>", it will be expanded to Abc : Foo at compile time, and for line "Abc<Goo> ", it will be expanded to Abc:Goo.
So, I think only one class named Abc exists in final binary after expansion, and it is the same as written Abc:Foo, Goo for the same effect?
class Foo
{
};
class Goo
{
};
template <class T>
class Abc : T
{
};
int main()
{
Abc<Foo> f;
Abc<Goo> g;
return 0;
}
regards,
George
|
|
|
|
|
George_George wrote: So, I think only one class named Abc exists in final binary after expansion, and it is the same as written Abc:Foo, Goo for the same effect?
Would you try to rephrase your question? For one thing there are no names in the final binary - machine code knows only about registers and memory, not types and variables.
|
|
|
|
|
Sorry for my bad description, Nemanja!
My question is
Abc < foo >
is expanded to Abc:foo and
Abc < goo > is expanded to Abc:goo . So, my question is C++ does not allow us to define a class "Abc" twice. But to my surprise, no compile errors. Any ideas?
regards,
George
|
|
|
|
|
George_George wrote: is expanded to
Well, it is not a macro espansion, the compiler takes care about.
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]
|
|
|
|
|
Thanks CPallini!
Are there any ways to see what the classes' looks like after template instantiation/expansion?
regards,
George
|
|
|
|
|
Oh, you may use the following little dirty trick, change slightly your template class,as follows
template <class T>
class Abc : T
{
public:
void missed();
};
and your main function
int main()
{
Abc<Foo> f;
Abc<Goo> g;
f.missed();
g.missed();
return 0;
}
This way, since missed method definition is missing the linker will complain about 2 'unresolved external symbol' and you may see the decorated function names. On my system I get:
?missed@?$Abc@VGoo@@@@QAEXXZ
?missed@?$Abc@VFoo@@@@QAEXXZ
i.e. the function name is decorated using both class name (Abc ) and template argument name (VGoo & VFoo ).
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]
|
|
|
|
|
Thanks CPallini,
Then could I understand in my original sample, there are actually 4 classes (without name decoration)?
- Foo;
- Goo;
- Abc < Foo >;
- Abc < Goo >;
regards,
George
|
|
|
|
|
What I think is 'class T' in the template is used as a Data Type declaration, and not just the pre compile replacements (as you expected Abc : Foo or Abc : Goo). So, you can use the T for member variable declarations in the class Abc, and not for the inheritance.
Compiler does replace the 'T' in the template, except the part of the template or class definition. So, you'd never find as 'Abc : Foo' or 'Abc : Goo'. This may help you.
- Malli...!
|
|
|
|
|
Thanks Malli_S,
I think template expansion is happening at compile time. After template expansion, what are the final classes?
regards,
George
|
|
|
|
|
You're right George, template expansions are done are compile time. I was just giving you thought that it's not just the replacement. The template instantiations are done when compiler comes across the class template's object declaration. In case of
template <class t="">
class Abc
{
T m_iVariable;
...
};
int main()
{
...
Abc <int> objInt;
Abc <double> objDouble;
...
Abc <int> objInt2;
}</int></double></int></class>
when the compiler comes across the statements
Abc <int> objInt;
Abc <double> objDouble;</double></int>
it generates the code for respective data types, which is called as template instantiating. These instants (generated code) persists through you program within it's scope. i.e. no more template instance is generated for 'objInt2' as the 'int' version of the template is already in exist.
- Malli...!
|
|
|
|
|
In my sample,
Abc < Foo >
will be expanded to
Abc:Foo
And
Abc < Goo >
will be expanded to
Abc:Goo
So, class Abc will be defined twice. So I think there is conflicting. Any ideas or comments?
regards,
George
|
|
|
|
|
I think template class names will be name mangled
Regards,
Sandip.
|
|
|
|
|
What do you think will be the classes' after template instantiation/expansion, Sandip?
regards,
George
|
|
|
|
|
Hi George,
I am not sure exactly what will be the class names. I even dont know any way through which you can see the class names after expansion.
I tried
class Foo: public CObject
{
public:
int add(int a , int b)
{
return a+b;
}
};
class Goo : public CObject
{
public:
int add(int a , int b)
{
return a+b;
}
};
template <class t="">
class Abc : public T
{
};
</class>
I used CObject because this enables my class to have RTTI.
now when i step in the respective add functions i see following contents in the watch window
this VFoo::?$abc
this VGoo::?$abc
Regards,
Sandip.
|
|
|
|
|
Thanks Sandip,
So in your sample, actually there will be two classes Abc < Foo > and Abc < Goo > , other than a single Abc class?
regards,
George
|
|
|
|
|
George_George wrote: So in your sample, actually there will be two classes Abc < Foo > and Abc < Goo >
Yes there will be two classes
George_George wrote: other than a single Abc class?
I doubt that this will be there
Regards,
Sandip.
|
|
|
|
|
Hi Sandip,
You mentioned in your experiment, you watched window likes this,
this VFoo::?$abc
this VGoo::?$abc
My question is what variable/object are you watching on to get such results?
regards,
George
|
|
|
|