|
By the by, Johann, what is a POD??
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
Oh, sorry. POD = Plain Ol' Data, int s, double s and such goodies.
--
The Blog: Bits and Pieces
-- modified at 17:18 Saturday 24th September, 2005
|
|
|
|
|
hi,
im trying to download a file with :
InternetReadFile [B]or[/B] URLDownloadToFile.
i did succeed to work with those functions - [B]BUT![/B] i want to download from the server and not use the cache files.
i did tried to add some flags of no cache use but with no success.
anyone got any inlights?
Avi.
visit me at www.laviadlab.com
|
|
|
|
|
Hi,
Have you tried DeleteUrlCacheEntry to get rid of the actual url, so it has to download the url again?
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
Hello All,
Say, is there anything akin to a family tree app for classes and their inheirited children, typedef class template wanta be's, etc.? Flippping back and forth between declarations and definitions, tracking back 4-12 levels of header files leaves me wondering what it was I trying to figure out to begin with.
There's got to be a better way.
So is there any open source that will show visual relationships? Even a plain text outline would be better than my strained brain cells.
Or do I have to take yet another deviation from my destination and write one myself?
Thnks
|
|
|
|
|
I've got a problem. I'll get input to my program and I have to determine which type of data that is. Input will occur in a text file and will look similar to this:
<br />
Add: 41.4 51.8 48.4 22.1<br />
Delete: 84.1 57.4 15.1<br />
etc....<br />
The problem is I have to determine the type of the data that needs to be added to the tree.
The tree is a template class.
I want to know code that could do the same as the following is supposed to do:
<br />
typedef T;<br />
T = int of T = double;<br />
AbstractTree<T> *tree = new BTree<T>;<br />
I then want to use type T in the rest of my program. etc.
AbstractClass<t> *tree = new BTree<t>;
I need this for a project that needs to be in on Monday 20:00(GMT)
Your help will be greatly appreciated.
Thanks alot
|
|
|
|
|
You need something to parse your input with like a char str and extract your numerical into a double. int doesn't do decimal so how do you know if a decimal is in your input?
It's a text file input so it's automatically a char going in. atof() and isalnum() would be my first thought or get out your ASCII table if you want to build your own smarter atof() to parse your entire input line at a time.
I don't know of anyone that wants to just hand you an answer to copy.
Remember the basic purpose of a template it to reduce redundant code differing only in parameter type, allowing the same call with different types.
But then again maybe I'm not understanding what you are doing, like are you pulling the entire input file into a buffer or are you grabing input by keyword, space, line ??
|
|
|
|
|
I'm grabbing input word by word.
instead of coding:
<br />
if (input is numeric)<br />
if (input contains '.'){<br />
AbrstrackTree<double> *p = new BTree<double>();<br />
AbrstrackTree<double> *p = new BStarTree<double>();<br />
AbrstrackTree<double> *p = new BPlusTree<double>();<br />
AbrstrackTree<double> *p = new Trie<double>();<br />
}<br />
else {<br />
AbrstrackTree<int> *p = new BTree<int>();<br />
AbrstrackTree<int> *p = new BStarTree<int>();<br />
AbrstrackTree<int> *p = new BPlusTree<int>();<br />
AbrstrackTree<int> *p = new Trie<int>();<br />
}<br />
<br />
if (input is char*){<br />
AbrstrackTree<char> *p = new BTree<char>();<br />
AbrstrackTree<char> *p = new BStarTree<char>();<br />
AbrstrackTree<char> *p = new BPlusTree<char>();<br />
AbrstrackTree<char> *p = new Trie<char>();<br />
}<br />
I want to do something similar to:
<br />
typename int T;<br />
AbrstrackTree<T> *p = new BTree<T>();<br />
AbrstrackTree<T> *p = new BStarTree<T>();<br />
AbrstrackTree<T> *p = new BPlusTree<T>();<br />
AbrstrackTree<T> *p = new Trie<T>();<br />
I'm trying to find out if there's a way of changing the type of T at run-time
|
|
|
|
|
So you're trying to ring my bell because now you are creating ambigious function pointers.
|
|
|
|
|
As far as I can remember once a type is defined that's it. The compiler does the conversion from T to int/double/long/etc. So at run-time there is no T, it as become a known integral type so you can't change it.
Also your code above is really strange and does not make much sense. But I really don't get what the real problem is. If you define T as double (as per VaporTrace) then you can set it as an integer or decimal from your input.
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
The problem is that the input I an getting can be of any basic data type....int, double,char..etc
My data-structure is using templates that is been made at compile-time, but I need the type to change in real time. I think there is a way to do it using a derived class of the template class, but I can't seem to figure it out.
I'm sure many people had the same problem before with something like using a STL vector or list, and not knowing what type of data will be stored in the vector, at compile time.
Please help!!
I hope I explained my problem clearly.....?
|
|
|
|
|
Hi,
Ok, the way you could do it is by creating a union. Seeing the you need types int, double and char, just create a union of them all:
typedef union
{
char c;
double d;
int i;
} UTYPES;
This way you can use that for your template class. Now which ever type you need it will be in the union. But remember to be careful how you treat the union. You will also have to do some nifty programming in the template class to get around not being an exact type. The best would be a container class for it so that you can have some control over what values are stored in the union.
Hope this helps.
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
We'll try that.
Thanks alot for your help.
|
|
|
|
|
Please help, and give me some details.
thanks
Lee
|
|
|
|
|
Of course. Like this:
class A
{
~A()
{
}
}; But I somehow wonder if you really didn't mean something altogether different, like "what will the implications be if I..." [1] or "when would I ever want to..." [2]. But, since it's Saturday evening, I couldn't possibly know, could I?
[1] You a) cannot do A* pA = new A; delete pA; and b) are prevented from making a local or member instance of A , since the compiler will automatically try to call the destructor when it goes out of scope.
[2] Perhaps a self-destructing object. Anyone can create it, but it can only destroy itself; no one else is allowed to destroy it. (Usually it will say delete this inside a member function.) If the object can only be safely destroyed under very specific circumstances, this can be a useful enforcement policy to prevent premature destruction.
--
The Blog: Bits and Pieces
|
|
|
|
|
Man, that's some good information. I never thought about it like that.
Can you help answer my questions posted below about pointers in C++?
Thanks.
|
|
|
|
|
Yes you can. That will cause that the class can only delete itself!
Don't try it, just do it!
|
|
|
|
|
Hi,
I have a question in c, can any body solve this problem
#include<stdio.h>
void change()
{
/*Write something in this function so that the output of printf in main
function should give 5 . Do not change the main function */ }
void main()
{
int i=5;
change();
i=10;
printf("%d",i);
}
rajesh
|
|
|
|
|
One answer is to use an inline assembly command to modify the return address to skip the i=10 part.
John
|
|
|
|
|
Hi John,
I think you might run into compiler problems when it generates code to return from the function. The best would be to change the values of the current stack (if the values of pushed on to the stack).
There is of cause the sneaky way around this. All you have to do is declare a static version of printf (e.g. static int __cdecl print (const char *format, ...) ). This way the compiler will link to this rather that the one in stdlib. Then you can print anything out you like.
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
First, I appreciate any help or insight you can provide. Also, if there is a book or place wherin I can read up on the information I seek, please feel free to let me know. I am teaching myself how to program in C++.
My question regards pointers.
Assume: SomeObject * objectPtr = 0;
Assume: OtherObject * smallObjectPtr = 0;
Assume that SomeObject has member: OtherObject * leftPtr;
Also, each OtherObject object has member: OtherObject *leftPtr;
Note: this is from a binary tree node insertion and deletion attempt.
Assume that objectPtr has been pointed to an object of type SomeObject (Tree class) and that smallObjectPtr (Tree node class) has been pointed to an object of type OtherObject in a binary tree. Also, assume that these nodes are nestled midway down the tree and all the nodes at the level have at lest one or two children.
What is the difference between the following two declations:
*objectPtr->leftPtr = *smallObject->leftPtr
and
objectPtr->leftPtr = smallObjectPtr->leftPtr
Afterwards, I assign the pointers I have used to null.
Will the two result in different assignments?
How can I tell which one to use? Essentially, I want to know how the inclusion of the “*” dereference operator changes what happens.
This problem occurred because during the binary tree deletion attempt, the proper assignments were made via pointers to the different nodes, but any attempt to print the contents of the tree afterwards results in less than half of the remaining tree being printed.
Finally, is there anything wrong with the following declaration and what does it mean (or vice versa regarding the "*" dereference):
objectPtr->leftPtr = *smallObject->leftPtr;
Thanks, I appreciate any help you all can provide. If there is any way I can be of help or assistance to you or the community, let me know.
-- modified at 20:02 Saturday 17th September, 2005
|
|
|
|
|
First assume
objectPtr->leftPtr = 1111
and
smallObject->leftPtr = 2222
then
BlitzPackage wrote:
objectPtr->leftPtr = smallObjectPtr->leftPtr
will assign the value of 2222 to objectPtr->leftPtr
while
BlitzPackage wrote:
*objectPtr->leftPtr = *smallObject->leftPtr
This will assign the contents of the object pointed to by smallObject->leftPtr to the object pointed to by objectPtr->leftPtr. In otherwords it will call the assignment operator [i.e. the OtherObject::operator=(const OtherObject&) function].
BlitzPackage wrote:
objectPtr->leftPtr = *smallObject->leftPtr;
Is there anything wrong here? That depends on the definition of the class OtherObject. But the answer is usually, yes. The diference is if the OtherObject class overrides the address-of operator (&) [i.e. the OtherObject* OtherObject::operator&() function], which would return the address of an OtherObject, premuably "this".
|
|
|
|
|
Thanks Ahz. I appreciate your answer and will continue to ruminate over it. Pointers are indeed one of the most challenging parts of C++ to understand, but it is nonetheless essential to so much else that I must master it.
Thanks again.
|
|
|
|
|
Hi,
if you don't like pointers have a look at references (int&).
The main difference is: You can't have NULL references.
Regards
Achim Klein
We can do no great things, only small things with great love. - Mother Theresa
|
|
|
|
|
Achim,
Can you implement binary trees (and other data structures) with references?
It's just a matter of time!
|
|
|
|