|
When you refer to 'the constructor', do you mean a static constructor, like in C#? C++ doesn't have static constructors. I don't know if C+0x is going to support that or not (it might be nice if it did).
With an instance constructor, you can set static members just like instance members. Each instance of a class can modify a static member.
I'm not sure what you're saying is missing .
|
|
|
|
|
Gary R. Wheeler wrote: like in C#? C++ doesn't have static constructors. I don't know if C+0x is going to support that or not (it might be nice if it did).
Yeah something similar.
Gary R. Wheeler wrote: With an instance constructor, you can set static members just like instance members. Each instance of a class can modify a static member.
Yup, but for example:
class CodeProject
{
static int x;
int y;
CodeProject()
{
x=0;
y=0;
}
};
The above won't work without we initializing it again in the .cpp.(int CodeProject::x=0 ). In specific it must be in .cpp - it won't work if we initialize the static member in the header. Just thought about these limitations & felt it might be possible to disguise a static member as an instance member and treat it the same way. (though internal implementation would differ).
And yup, I wish C+0x have this feature unless they've been following this way for any specific reasons.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Stricly speaking, you don't have to initialize the value when you define it:
int CodeProject::x; in the CPP source file. The language designers left it up to the programmer where to place the definition, rather than arbitrarily placing it somewhere themselves. Interestingly enough, the C++ language places relatively few requirements on where in your source code you do things.
|
|
|
|
|
Gary R. Wheeler wrote: Stricly speaking, you don't have to initialize the value when you define it:
Yeah the proper word to address that would be to "Define"-it-again.. but to exercise discipline I initialized it & hence called it "initialize".
Gary R. Wheeler wrote: n the CPP source file. The language designers left it up to the programmer where to place the definition, rather than arbitrarily placing it somewhere themselves. Interestingly enough, the C++ language places relatively few requirements on where in your source code you do things.
Yeah but why not they allow us to define it in the constructor? As we have declared the member as "static" the compiler would be aware - it's a static one and allocate memory accordinly. That's possible right? But why does it get fussed up and asks the user to do all these? .. that was my thought. Or I'm missing something?
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
VuNic wrote: why not they allow us to define it in the constructor?
There isn't a way for the compiler to tell the difference between initialization, which you only want to do once for a static member, and a normal assignment, which you may want to do every time you construct a new instance.
|
|
|
|
|
Gary R. Wheeler wrote: here isn't a way for the compiler to tell the difference between initialization, which you only want to do once for a static member, and a normal assignment, which you may want to do every time you construct a new instance.
Yeah.. the compiler could've been equipped with that awareness.
Gary R. Wheeler wrote: delete this;
Within the context quite!. lol
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
VuNic wrote: The above won't work without we initializing it again in the .cpp.
You aren't (just) initializing it - you are defining (i.e. reserving storage for) it.
If you could define (as in reserve storage for) the static item in the class definition, then where would the static item's storage live? Each .cpp file that included the header with the class definition would contain storage for the item. You would need some intelligence in the linker to merge all allocations of the static item. Now, that intelligence might exist today, but it sure didn't back when Bjarne designed C++.
I suspect the Annotated C++ Reference[^] might well provide insight into these design decisions. I have got and have read that book, but not for a while.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Explanation here[^] Yep,I meant definition.
Stuart Dootson wrote: You would need some intelligence in the linker to merge all allocations of the static item. Now, that intelligence might exist today, but it sure didn't back when Bjarne designed C++.
Exactly, what I tried to think! Also thanks for the link.. could be the 4rd book on C++.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Can you give a real example of where you would use this ?
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
C# - static constructors.
The idea is not going to be revolutionary. But as I said, it'd be better for the coder. A neat idea.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
I realize C# has static con, but i was looking for a real world use in C++.
The only example i can think of is where the static is a pointer to a dynamically allocated object. The static cons would alloc, the static des would free.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
cmk wrote: but i was looking for a real world use in C++.
Any example where you use a static variable would do. My thought is simple. A class can continue to represent it's core, solid members, in addition to that, it could house static variables and mimic the usage of static variables as if they are members of the class, instead of the messy-current implementation. C# static constructor looks like one way of managing the static clutters inside the class. The idea sounded good at least. Stuarts had better expressed the same below. You might look at that one too.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
In addition to the above comments, also notice that you might access a static variable of a class before you have any instances of it.
|
|
|
|
|
Niklas Lindquist wrote: In addition to the above comments, also notice that you might access a static variable of a class before you have any instances of it.
leaves me thinking. Yep so C# is right by having a static constructor. I think it takes care of this scenario. Let me dive into it & test . Thanks man
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Hi to all,
Please suggest me a good 'AVC/H.264 Video Decoder", having 'Quarter Resolution' property.
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|
|
Hi,
I am creating a filtergraph in DirectShow (windows).
How can I use libavcodec in my case?
Simulated filter graph is,
"MPEG-2 Multicast Receiver" --> "MPEG-2 Demultiplexer" --> "Video Decoder" --> "Video Renderer"
It is receiving H264 ASI Stream.
I am creating an output video pin 'v1' to "MPEG-2 Demultiplexer" with following settings,
<br />
VideoInfoHeader hdr = new VideoInfoHeader();<br />
hdr.BmiHeader = new BitmapInfoHeader();<br />
hdr.BmiHeader.Compression = 0x68323634;<br />
<br />
vid_media.majorType = MediaType.Video;<br />
vid_media.subType = ExtraFunctions.MediaSubTypeH264;<br />
vid_media.formatType = FormatType.Mpeg2Video;<br />
vid_media.fixedSizeSamples = false;<br />
vid_media.temporalCompression = false;<br />
vid_media.sampleSize = 0;<br />
vid_media.formatSize = Marshal.SizeOf(hdr);<br />
vid_media.formatPtr = Marshal.AllocCoTaskMem(vid_media.formatSize);<br />
Marshal.StructureToPtr(hdr, vid_media.formatPtr, false);
Pin 'v1' is not connecting to "ffdshow Video Decoder". I can connect pin 'v1' to "MainConecpt AVC/H.264 Video Decoder". "MainConecpt AVC/H.264 Video Decoder" is not having resolution setting, which I want to set as 'Quarter'.
Michael Schubert wrote: http://ffmpeg.mplayerhq.hu/index.html[^] ?
How can I use libavcodec?
Is there any onther video decoder?
Is there any thing wrong in video output settings?
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|
Guid H264SubType = new Guid("8D2D71CB-243F-45E3-B2D8-5FD7967EC09B");
|
|
|
|
|
Aniket Salunkhe wrote: How can I use libavcodec?
I don't know, you have to get famliar with the API. I just know that many video tools use this library because it's open source and works apparently pretty well.
|
|
|
|
|
Hi,
I think I am missing some thing while creating H.264 video output pin to "MPEG-2 Demultiplexer". Because that pin is not connecting to most of the H264/AVC Video Decoder.
Please guide me to create video output pin (for H.264) to "MPEG-2 Demultiplexer".
Actually I want to render multiple multicast sources which are in H.264 format.
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|
I checked the compiler command line,
only /Yu and /Fp there for pch,
and all works well.
But when I create an empty win32 project,
and try to enable the pch mechanism in the same way
(the same compiler command line, also add the default stdafx.h/cpp),
it doesn't work.
What is the problem?
BTW, it's tested in VS2008.
|
|
|
|
|
The /Yc option is set only for stdafx.cpp, over-writing the project default of /Yu.
Right-click on stdafx.cpp and check its properties - you'll see /Yc set.
You can do the same thing in your Win32 project (set /Yc for stdafx.cpp rather than /Yu).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
for (int l=0;l<5;l++)
{
DBGetText(hWndGet);
TextInfoSend(hWndSend, ts);
hTimer = CreateWaitableTimer(NULL, FALSE, NULL);
LARGE_INTEGER liDueTime;
liDueTime.QuadPart = -1000LL;
SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0);
(WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0);
CancelWaitableTimer(hTimer);
All the above minus the for loop works when inserted in a command button.
HWND hWnd1;
hWndout = FindWindow("NotePad",NULL);
if (hWndout)
{
l=2;
}
}
After having done the for loop my data only refreshes when I exit the loop.
BTW I am using WM_COPYDATA inside TextInfoSend function to transmit data.
Can someone shed somelight as to what I have missed to get my data to refresh.
Thanks A Million.
|
|
|
|
|
I'm not completely sure what you are trying to accomplish there but my guess would be that your loop runs in your GUI thread, this means, no messages will be processed during the workings of the loop, thus the unrefreshed and unreponsive GUI (if your loop takes longer then windows will also consider your process unreponsive and you probably will get the nice "Not responding..." text in the titlebar of your main window - if you have one that is). To avoid this you can try putting your loop in a separate thread.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Yes. That is whats happening. I guess since i am new at this, there was nothing in the code that I have done wrong. My next dumb question is How do I create a new process from the GUI.
thanks a million.
|
|
|
|