|
Just wondering because...some things...strings, iterators, lists, etc are nice and clean in java and c#, but are ugly or lacking in c++.
Over time i see code project articles try to bring some of that c# goodness to c++, like with delegates, foreach, and properties...so is their any library out there that does this in a big way...make c++ like C# with memory leaks i mean :P
|
|
|
|
|
|
If you've looked at Boost you'd be asking the opposite question. For example the multi index containers and the Boost graph library are unbelivable and only available in C++. Some of what you mention has been available (in the STL) for years, in fact before dotNET even existed - std::string and iterators for example.
Steve
|
|
|
|
|
Hi,
I am having a 16bit ascii file which contains signed integers from -8191 to +8191. These integers are stored in a file in a single row without any delimiters. Can anyone gimme a sample code which can read this kind of file for the signed integers (b/n -8191 and +8191) stored in it or do I need any more info to perform this?
thanks,
-Pav.
|
|
|
|
|
So are you wanting to read the file two bytes at a time? If so, just use a short . To see if you are on the right track, try:
FILE *pFile = fopen("", "rb");
short num1, num2, num3;
fread(&num1, sizeof(short), 1, pFile);
fread(&num2, sizeof(short), 1, pFile);
fread(&num3, sizeof(short), 1, pFile);
fclose(pFile); Now if num1 , num2 , and num3 are correct, you're on your way.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
What do you mean by "16 bit ascii"? Do you mean a UNICODE text file? or do you mean that the numbers are stored in a 16 bit binary format (every 16 bits or two bytes is another number)?
How the the numbers are stored in the file will determine how you have to read it.
You may be right
I may be crazy
But it just may be a lunatic you’re looking for
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
It's a 16 bit binary format. The numbers are stored one after the other without any delimiters.
thanks,
-Pav
|
|
|
|
|
So the file is a series of short s. Simply open the file and read in one short at a time.
You may be right
I may be crazy
But it just may be a lunatic you’re looking for
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Has anyone built a C++ app that uses the STL but does NOT use the CRT? Is this possible?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Not possible, STL uses the CRT.
You may be right
I may be crazy
But it just may be a lunatic you’re looking for
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
I was thinking that in some ways, STL is the CRT so the two cannot really be separated...but here's a thought:
If you define the STL to be just a collection of header-files, and the CRT to be things like new[], delete[] etc
Then it would be possible to write your own implementation of global new[], delete[], plus provide a few other necessary house-keeping routines like mainCRTStartup. Add the compiler option to strip the CRT, and maybe one could cobble something together which, when linked to your 'custom' CRT, could be twisted enough to meet the original requirement...
can't imagine why anyone would want to do this..
james
http://www.catch22.net
|
|
|
|
|
I have oppsite question. it should have more sense.
if you do not use stl stuff ,how to unlinke stl lib from my project?
it seem stl is default linked to any c++ project(I use vc)
|
|
|
|
|
What can be used on windows xp to debug an application at runtime? I cant step through it because its an exe thats launched by another exe, and it calls some dlls, which might be where the problem is occuring,
thanks,
sb
|
|
|
|
|
Is there a way of sending my class a pointer to my view's DC. I would like to draw to the DC and then "blit" it back to the screen. Until now I have only been able to get the DC for the main window.
Thanks.
|
|
|
|
|
CFrameWnd::GetActiveView will return a pointer to your CView derived window, you can call GetDC on that view
You may be right
I may be crazy
But it just may be a lunatic you’re looking for
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
I tried what you suggested and I get an "illegal call of non-static member function" error.
CView* pView = CFrameWnd::GetActiveView();<br />
CDC* pDC = myview->GetDC();
I am new to the whole MFC programming scene so I am sure I am doing something really silly.
Thanks for the help.
-- modified at 14:00 Tuesday 28th February, 2006
|
|
|
|
|
masnu wrote: CView* pView = CFrameWnd::GetActiveView();
GetActiveView() is not a static function (i.e., one that can be called without an actual object). You must call it in the context of a CFrameWnd object, not CFrameWnd itself.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
David,
From what you said I assume I need to put the code in my CMainFrame class, which I did. I no longer get a compiler error, but I get an access violation error in the objcore.cpp file:
BOOL CObject::IsKindOf(const CRuntimeClass* pClass) const<br />
{<br />
ENSURE(this != NULL);<br />
ASSERT(AfxIsValidAddress(this, sizeof(CObject)));<br />
<br />
CRuntimeClass* pClassThis = GetRuntimeClass(); <br />
<br />
ENSURE(pClassThis);<br />
return pClassThis->IsDerivedFrom(pClass);<br />
}
What I have is:
void CMainFrame::Scroll()<br />
{<br />
CDC* pDC = CFrameWnd::GetActiveView()->GetDC();<br />
<br />
CStripChart* pStrip;<br />
pStrip->Scroll(pDC);<br />
}
Any suggestions?
Thanks.
|
|
|
|
|
masnu wrote: CStripChart* pStrip;
pStrip->Scroll(pDC);
This looks suspect. How has pStrip been initialized?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
When I debug, that code doesn't even run. The problem occurs when
CDC* pDC = CFrameWnd::GetActiveView()->GetDC();
is executed.
CStripChart is just a class I created to accept a DC and draw a grid to it and plot what ever data is sent to it. I have scroll function as a seperate thread. Could this be a problem?
Is there any way I can get a pointer to the view's DC and pass it to my class for furture use? Or would I need to pass a new DC everytime I wanted to update my window?
|
|
|
|
|
What does GetActiveView() return? If it is NULL , then dereferencing the pointer will cause problems.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
It doesn't return anything. I get the error before it returns.
|
|
|
|
|
When/how is CMainFrame::Scroll() called?
masnu wrote:
I get the error before it returns.
Since GetActiveView() and GetDC() are called within the same statement, are you sure?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
As a quick test I modified the app's file open command:
ON_COMMAND(ID_FILE_OPEN, &CMainFrame::Scroll)
|
|
|
|
|
masnu wrote: ON_COMMAND(ID_FILE_OPEN, &CMainFrame::Scroll)
What is the ampersand doing there?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|