|
|
justhere19 wrote: Is there no way to do this?
Yes, there is a way.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I'm trying to create a class where one of the member variables needs to be an array of variable size.
"Great" thinks I, "Vectors are nice". Unfortunately I can't use a template within a class definition.
Any suggestions? Char or unsigned int data is fine.
|
|
|
|
|
You could make the member variable a pointer then reallocate the memory when you need to with realloc() .
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
Never mind Vectors, Templates are not omnipotent. The classic way of dealing with this is, to use a member_pointer to the data Object. Set this pointer to 'Empty'(whatever this means in your case) in the Class Constructor. If the data object has to grow dynamically, you want to provide for this in it's declaration and definition, for instance by an AddItem(...) type of function. You can also write Load(..) and Save(...) functions so Load or Save from or to Disk (Sorry, Persistent Storage)
regards
Bram van Kampen
|
|
|
|
|
I can use CArray as a member variable without having to write any of my own support functions.
For some reason vector wouldn't compile - yes I did have the include.
|
|
|
|
|
Trollslayer wrote: For some reason vector wouldn't compile - yes I did have the include.
This compiles fine:
class MyClass
{
public:
MyClass() {}
~MyClass() {}
private:
vector<string> m_vectNames;
};
void main( void )
{
MyClass m;
}
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Trollslayer wrote: Unfortunately I can't use a template within a class definition.
Why not?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
As I said above
who can give me a example
I have some confuse about implementation of interface in C++
Lots of people gave me a variety of advises
such as multiple inheritance
Thanks a lot
|
|
|
|
|
I'm afraid this is to general question worth of a full size article. Give some more specific problem which folks could dispute on.
|
|
|
|
|
york528 wrote: I have some confuse about implementation of interface in C++
What kind of interface? a graphical USER interface?
Regards,
--Perspx
Don't trust a computer you can't throw out a window
-- Steve Wozniak
|
|
|
|
|
Hi
i want to export my cookies from IE to a text file like what exactly IE doing and how import cookies functionality working
----------------------------
KRISHNA KUMAR T M
|
|
|
|
|
hi,
i am developping an mfc application than need to handle a large amount of data.
my PC have 3Gb of physical RAM (i am using only 700MB of it).
I can not understand wy i can´t allocate more than 400 continus Mega bytes with new[] or malloc.
like this: short *buffer = new short[200000000]; or short *buffer = (short*) malloc(400000000);
I do not know if there is something to do with heaps size ??
Thank you for your help.
|
|
|
|
|
Have you tried a Win32 function like LocalAlloc() or GlobalAlloc()?
Also, 400MB is 400 x 1,024 x 1,024 = 419,430,400 bytes, not 400,000,000 bytes.
Regards,
--Perspx
"The Blue Screen of Death, also known as The Blue Screen of Doom, the "Blue Screen of Fun", "Phatul Exception: The WRECKening" and "Windows Vista", is a multi award-winning game first developed in 1995 by Microsoft" - Uncyclopedia
Introduction to Object-Oriented JavaScript
|
|
|
|
|
Do you realy need all this data in memory, all at the same time?
Things like arrays of data are nice to work with, but, if it becomes unreasonably large, (and I would call 400 MB too large to work with), you employ a different approach. You open the File, and read small sections from which you work out where to go next,and so on.
Why things do not work in your case is a different matter, and has most likely to do with where the OS puts things in the LOGICAL Address Space.
For Instance, the area from 2GB to 4GB in your logical address space is reserved by the system. You would not get memory allocated there even if you had 16 GB of memory.
Admittedly, Microsoft does not encourage this approach, their User MFC Document Model was until recently that a Document is something like a Word Document or a Spread Sheet which is Loaded, Modified and Saved each time in it's entirety. That is not a very useful model for large amounts of Data.(You cannot load say a 64 kb Block out of the middle of a CDocument).
Where amounts of Data became large, I devised my own DB Structure, and never read entire files, just the sections I Need. I also found it useful to create and store Hash Tables to speed up searching.
Hope this is Helpfull,
Bram van Kampen
|
|
|
|
|
thank you for your responses but the thing is that i am working with medical data from CT images (3D ray casting) and the data must be in memory so the rotation of the 3D object can be fast.
I can do more that one allocation (100 of 4 MB) but i would prefere only one of 400 or 600 or more even when I have 3 GB of RAM.
|
|
|
|
|
Well, I've never dealt myself with a single object of say 400 MByte.
I do not think that the OS was designed to deal with that either, Furthermore, any software I have seen dealing with objects of this size tended to split them down. The OS can however deal with items aglomarating to this size and larger, provided they are not required to occupy a continuous logical address range. There is a difference between what you would prefer to get optimal performance, and what the OS for practical reasons allows you to do on the ground. In your case I would write it on the basis that it tries every time for the largest chunk of memory it can get, and deal with it that way.
What Also may be worth trying is to try and create a 400 MByte heap, as early as possible in the Program. (In InitInstance, Line One, before the MFC Stuff.) Realistically though, If you expect your code to run on every PC in the country, you have to prepare your code for data in fragments. If you expect it to run on only One PC, (your Own) you can fiddle and tweak the OS until it runs allways with a 400 MByte Object.
Regards
Bram van Kampen
|
|
|
|
|
yes, maybe is the unique way to do it.
think you
|
|
|
|
|
ybenaabud wrote: I can not understand wy i can´t allocate more than 400 continus Mega bytes with new[] or malloc.
Are you sure that 400MB of contigious RAM is available? For example, you may have 1GB free, but if it is segmented in five 200MB chunks, the new operator will indeed fail.
Have you tried an amount smaller than 400MB?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Yes I think that the problem is memory fragmentation !! I can reach 1,9GB of allocated memory with differents new[] of 1MB each time.
does everybody knows how to turn maximum memory allocation from 2GB to 3GB on a 32 XP Pro PC for a process ?
|
|
|
|
|
ybenaabud wrote: does everybody knows how to turn maximum memory allocation from 2GB to 3GB on a 32 XP Pro PC for a process ?
I doubt everybody does. Are you referring to the /#GB option?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
yes /3GB in boot.ini. but when a do it in my windows xp pro pc with 3GB of physical ram I lose the network connexions !!
|
|
|
|
|
ybenaabud wrote: but when a do it in my windows xp pro...
See here and here.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi everybody,
I have been having problems with http post using visual c++ (not .Net)
Here is my code:
CInternetSession session("My Session");
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
DWORD dwRet;
char szBuff[1024];
try
{
CString strServerName = "http://www.cnn.com";
INTERNET_PORT nPort = 80;
pServer = session.GetHttpConnection(strServerName, nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, "");
pFile->SendRequest();
pFile->QueryInfoStatusCode(dwRet);
if (dwRet == HTTP_STATUS_OK)
{
...
Well I have tried a lot of code combinations. And when I realized application crashes at
pFile->SendRequest(); I decided to make a GET instead of POST. Well it still does not work.
When I run the code above I got a MessageBox saying The URL is invalid
And when I run with AddRequestHeaders(NULL) line it basicly crashes..
I have done a research at web but cannot find anything useful.
My main purpose is to open a URL which I can do it using session::openurl and after getting the content post a form and get feedback from post.
Thank you all
--- OK People the problem is solved. Guess what I SHALL NOT WRITE HTTP:// at the beginning of URL! I guess msdn should contain such an info!
modified on Saturday, September 6, 2008 11:08 AM
|
|
|
|
|
Hi all,
please tell me how can i repaint a view.
if possible please explain with example.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|