|
Cedric,
Thanks for the quick response, your help and suggestion. This is a great web site. Really starting to love it. Complied with no errors!
|
|
|
|
|
On the brighter side, it feels good to see people like you, who would take our advise and acknowledge the help received. You can mark his reply as "Good Answer" if you wish to add reputation to him.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
If you're explicitly using std::wstring, then
std::wstring transType=L"MU";
is probably more appropriate than using _T("MU") . The L prefix on the string marks it as a wide-character string literal whether you compile for Unicode or ASCII, which matches std::wstring, which also is a wide-character string whether you compile for Unicode or ASCII.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi all,
I want my .txt file to be saved in unicode big endian encoded one..
i am using fwrite function...
but its not writing properly..its showing some junk characters..
Does fwrite function allow us to save in unicode big endian format??
Please let me know for further clarifications..
thanks,
rakesh.
|
|
|
|
|
|
Hi Selvam,
Thanks for your reply..
Can you please enlighten me about the content u referred??
can you please tell me how can we make fwrite to support unicode big endian type..
thanks,
rakesh
|
|
|
|
|
|
Hi all,
Having a problem with polymorphism and returning a class from a function.
Suppose I have base class B which is used to derive D1, D2, D3, D4, etc..
Suppose a function of B, myFunc(), has return of type B, and myFunc() creates within it a D1, D2, D3, or D4 and returns it.
If I were to try the following in a separate, or main(), function somewhere else,...
B rtn_instance = B::myFunc();
....how come rtn_instance is still of type B and not of type D1, D2, D3, etc... ?
I thought the polymorphism would make rtn_instance of type D1, D2, etc...
Maybe references would be helpful, but doesn't using references pose a memory leak risk, or do the pointed to objects get destroyed on exit from the calling function?
Many thanks for any help.
|
|
|
|
|
figured it out...
i should be using references.
Hurrah !
|
|
|
|
|
Let's do some actual code...
class B
{
public:
virtual B & myFunc () { return *this; }
virtual void SayMyName () { printf ("B"); }
};
class C : public B
{
public:
virtual B &myFunc () { return *this; }
virtual void SayMyName () { printf ("C"); }
}
main ()
{
C c;
B b = c.myFunc;
b.SayMyName ();
}
OK, pretty artificial, and I'm missing out on stuff.
It's pretty plain to me that a temporary B would be constructed, using it's copy constructor. Then if the compiler is not too clever, that temporary B would be copied to b.
If you want a polymorphic return, use pointers.
class B
{
public:
virtual B *myFunc () { return this; }
virtual void SayMyName () { printf ("B"); }
};
class C : public B
{
public:
virtual B *myFunc () { return this; }
virtual void SayMyName () { printf ("B"); }
}
main ()
{
C c;
B *b = c.myFunc;
b->SayMyName ();
}
Give that a go, I hope it helps.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
In addition to my answer (yours was a clue)
{
C c;
B &b = c.myFunc ();
}
would have been fine too.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Polymorphism works through pointers, for instance, try:
#include < iostream >
using namespace std;
class B
{
protected:
int b;
public:
B(int b){this->b = b;}
virtual void out(){cout << "hi frm B, data value is " << b << endl;}
};
class D1 : public B
{
public:
D1(int i):B(i){}
virtual void out(){cout << "hi frm D1, data value is " << b << endl;}
};
class D2 : public B
{
public:
D2(int i):B(i){}
virtual void out(){cout << "hi frm D2, data value is " << b << endl;}
};
B * myFunc(int i)
{
switch (i%3)
{
case 0:
return new B(i);
case 1:
return new D1(i);
case 2:
return new D2(i);
}
}
void main()
{
B * p, *q;
p= myFunc(5);
q= myFunc(6);
p->out();
q->out();
}
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 for all your help guys. I'm gonna stick with references because I'm trying to write something for users. I don't want to return actual pointers which require the "->" operator.
Cheers
|
|
|
|
|
hi want to make a simple tic tac toe game using simple 2d arrays.without pointers.if anyone have this code .then please reply
|
|
|
|
|
sam_2009 wrote: hi want to make a simple tic tac toe game...if anyone have this code .then please reply
So if somene else gave you the code, would you still be making it?
Why don't you start, and then ask for help when you get stuck on a specific task?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
make == compile
|
|
|
|
|
I don't have this code. Does that help?
|
|
|
|
|
You can make it Or try with Google for get logic for develop code.
Thanks and Regards,
Selvam,
http://www.wincpp.com
|
|
|
|
|
|
You should post your request in the 'plz sir send me codez plz plz' one.
BTW you lost 100 man points for attempting to avoid pointers.
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]
|
|
|
|
|
CPallini wrote: BTW you lost 100 man points for attempting to avoid pointers.
HA! 5.
|
|
|
|
|
|
Hi all,
Please let me , if you know anything about windows time providers(http://msdn.microsoft.com/en-us/library/ms725475%28VS.85%29.aspx[^]).
i want to
1. Sync my local machine time with any NTP server.
Is there any other method to do that.
I think, this is possible only through Windows Time Providers...
Thanks in advance
BIJU
|
|
|
|
|
Creating and implementing a time provider is different than simply communicating with a NIST server.
bijumanjeri wrote: i want to
1. Sync my local machine time with any NTP server.
Using sockets, you can use the DAYTIME protocol to connect to 129.6.15.28, port 13. I assume using the NTP protocol (port 123) is just as easy.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thank you David for your very quick response.
OK. Let me check with your suggestion.
BTW..
by going through the MSDN, I think, by using w32time.dll, we can control the Windows Time Service.
like forcefully sync with external NTPs. But how can we access the Windows Time Service?
Is there any APIs available for controlling the Windows Time Service?
Please help me.
Thanks
BIJU
|
|
|
|