|
CAll by value
Call by reference
suresh babu.k
|
|
|
|
|
I posted this for your information.
Do you have a genuine question to ask?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
surshbabuk wrote: CAll by value
Call by reference
See Here[^]
Try to understand yourself.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
1. A question in regular english starts with a CAP and ends with a question mark ( ? ).
2. A sentence should contain a subject, a verb, and optionnaly, some complements.
3. Once 1. and 2. are validated, express clearly what you want to achieve, and in what we can help you.
4. Don't ask the same question again and again. The forums are not chat chans, so use the same thread and use you browser scroll bar to reach it if it's gone too far...
sincerely,
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-- modified at 5:02 Wednesday 14th June, 2006
|
|
|
|
|
And guess what . You committed the same mistake for (CAP's).
3. once 1. and 2. are validated, express clearly what you want to achieve, and in what we can help you.
4. don't ask the same question again and again. the forums are not chat chans, so use the same thread and use you browser scroll bar to reach it if it's gone too far...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
in c++ function types are:
with retun type and with parameters
suresh babu.k
|
|
|
|
|
surshbabuk wrote: n c++ function types are:
with retun type and with parameters
Then what is problem with you??
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Yes .
Where in passing the values to the function you can decide whether you want them passed by value or as a reference depending on what your code is and how you are going to use the values.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi Coders
If you have lots of data that you reference in an application (eg thousands of widget codes, prices and corresponding .bmp files), I gather it's possible to serialise/encode/write that data from ASCII into a binary file so that the data takes up much less space and can be accessed much more quickly by your application than if it is left in ASCII.
Assuming you (1) do not want the actual data to be changed or added to after compilation by end users, but (2) you want your application to be able to quickly and efficiently reference individual items in the binary file, what do you think is the best way to include the binary file in a native Visual C++ Project?
Is it possible to embed the binary file in the native Visual C++ project so that it in the application's core exe/dll without a separate external bin file? Could I do this with a cpp, lib or resource item that contains all the binary data?
Any thoughts or suggestions would be much appreciated.
Regards
Jeremy
|
|
|
|
|
JSadleir wrote: what do you think is the best way to include the binary file in a native Visual C++ Project?
Add the binary data to the project as a resource then use the FindResource(Ex) , LoadResource , LockResource and SizeofResource APIs to access the data.
Steve
|
|
|
|
|
Thanks Steve - I'll give it a go - Regards Jeremy
|
|
|
|
|
class CSomeObject : public CObject<br />
{<br />
};<br />
<br />
CSomeObject *pObject = new CSomeObject;<br />
CSomeObject *pSave = pObject;<br />
But now I want to use the pointer of pSave, can I verify if pSave is valid or not before I use it?
try/catch?
or any method else?
-- modified at 23:26 Tuesday 13th June, 2006
|
|
|
|
|
Actually new returns '0' if it is unsuccessful.
you can use IsBadWritePtr or IsBadReadPtr to validate the pointer.
new will throw exception if it fails, u can also catch for that exception
See MSDN for more details
SaRath.
"Don't Do Different things... Do Things Differently..."
Understanding State Pattern in C++
|
|
|
|
|
Using IsBadWritePtr and friends will not solve the OP's problem. IsBadWritePtr can return FALSE even after an object as been deleted as heap blocks can be marked as free but the memory still be allocated. On top of this the CRT can add another level of caching. In short, if IsBadWritePtr returns TRUE you know something is wrong and it's not safe to use the memory, but if returns FALSE it does not necessarily mean all is well.
Steve
|
|
|
|
|
flyingxu wrote: But now I want to use the pointer of pSave, can I verify if pSave is valid or not before I use it?
try/catch?
or any method else?
Look up _set_new_handler , _set_new_mode , _query_new_handler , AfxSetNewHandler (this is not documented) .
The above functions transfers control to your error-handling mechanism if the new operator fails to allocate memory.
These functions (except for _set_new_mode and _query_new_handler ) take a function pointer as an argument and returns the old one. The _query_new_handler function returns the address of the current new handler.
Make sure you set the old one back before exiting.
PNH old_handler = _set_new_handler( my_handler );
_set_new_handler( old_handler )
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Of course, it is offtopic, but I would say that requirement to verify if pointer is good or not is a result of bad objects intraction design. There never should be invalid pointers, because you will forget to verify it once - either now or when you will have to modify your code one year later.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
Check this link[^]
Cheers
"Peace of mind through Technology"
|
|
|
|
|
flyingxu wrote: But now I want to use the pointer of pSave, can I verify if pSave is valid or not before I use it?
try/catch?
Use ASSERT in Debug mode B'coz it works in Debug mode only.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
You may use a smart pointer that implements reference counting, e.g. boost::shared_ptr<csomeobject>, instead of raw pointer.
|
|
|
|
|
hi there can anyone out there help me with "egavga.bgi" error
Adi
|
|
|
|
|
egavga.bgi is an Device driver file...
I think this is missing .
You have to download it and place it in valid location
Cheers
"Peace of mind through Technology"
|
|
|
|
|
anmol m wrote: hi there can anyone out there help me with "egavga.bgi" error
This error mostly seen in Turbo C++ Editers while doing graphics related work.
Set the BGI library path properly to work.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Exactly what error is being reported?
At runtime, your DOS program using the BGI needs this graphics driver file, unless you have embedded it into the executable.
More details are needed to correctly interpret the error.
this is this.
|
|
|
|