|
Hello,
I use a template class where I would like to overload the operator [ ].
My intention is that not only the instances of the class will call the operator but also the types of the instances.
I have tried the following code. It works but never the operator [] is called.
Please could tell me if is there a solution to use my own overloaded operator with any type like int, float, long etc..
Thanks for your kind answers.
//ClassTest.h
template <class type>
class ClassTest
{
public:
ClassTest(){};
virtual ~ClassTest(){};
type* Date;
inline type& operator[](UINT i_index){return (at(i_index));};
};
main()
{
// test 1
ClassTest <int> theInt;
theInt.Date = new int[10];
theInt.Date[0] =5; //Does not call type& operator[]
//test2
int array[] = {1996,1997,1998}
ClassTest <int> figure;
figure.Date = array;
int xx = figure.Date[1]; //Does not call type& operator[]
}
|
|
|
|
|
You haven't called the [] operator for the template class in either of your examples.
Instead of
theInt.Date[0] =5; // This is using default [] operator to index into the "Date" member.
it should be
theInt[0] = 5;
This will call your operator but it won't compile since you have no "at()" method defined.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi
I am making an application using VC++ now i want to run a bunner
i use the dialog based application .
Can any one tell me how we can do this
mailing me
Yogi
|
|
|
|
|
banner ? what is a banner for you ?
|
|
|
|
|
Banner like
" you are most welcome in to ......................"
mailing me
Yogi
|
|
|
|
|
WTF are you talking about ?
can't you explain clearly you need and what you have ?
|
|
|
|
|
I guess he wants to print a banner from a dialog based application
|
|
|
|
|
|
something like this ?
http://www.codeproject.com/staticctrl/bannerstatic2.asp
or like this ?
http://www.codeproject.com/miscctrl/kcsidebannerwnd.asp
|
|
|
|
|
i don't know if it's what the OP was asking for, but CKCSideBannerWnd rocks
|
|
|
|
|
|
if ( youdontspam )
{
youarewelcomehere
}
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.
|
|
|
|
|
if ( youdontspam )
{
breakpoint-->*youarewelcomehere //Yeah it reaches here!
}
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Is this some kind of sophisticated cross-posting?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Just tried *routing* people to the destination
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Hi
How do I open a new form from a running form ?
regards
|
|
|
|
|
|
Hi
I want to modify nonclient area of windows application,i.e. to modify font in caption, menu and so any body have some hint about this then please send me.
Thanks and Regards
Atul Mahajan
Atul
|
|
|
|
|
Look here [^].
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.
|
|
|
|
|
Is there any Tool Using which i can upgrade my VC++ Project to VC++.Net Project for Windows Vista.
|
|
|
|
|
With C++ it's easy - turn on the managed code option (/clr ) in your project settings, and rebuild.
|
|
|
|
|
hi !!!
i am using an Owner drawn ListBox which contains an icon and an associated string.
i am not able to load icon from the specified file path.presently i am importing to the resources and loading icon with the resource ID.
Need Help Urgently.
PHANI.
|
|
|
|
|
Use LoadImage with LR_LOADFROMFILE flag. See details on MSDN [^].
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.
|
|
|
|
|
hey my friend made the tic tac toe game and i will add the intelligent part to make it oneplayer Vs computer
i want to find a way to make a prolog dll and to access it using c#or c++
for example i have
predicate : player1(Move,Cpu_response)
so say i did the Dll file of visual prolog 5.1 now i need to access it through the C# or C++
in brief (how to link the prolog to C# or C++ )
FOR ISLAM
|
|
|
|
|
Hello,
I'm trying to make a program that will have to exchange information with another program. In order to be able to do that, I need to import one OCX and a couple of files: one file that has the extension CIE and another one that has the extension CLS.
Anyone has any clue on how to import those files?
I've googled it and I've not found anything interesting.
As always thank you in advance.
|
|
|
|