6,741 Posted Topics
Re: [B]>Can anyone explain me how the vtable and vptr are created >in case of virtual base class and what all values it contains.[/B] First and foremost, each compiler will do these things in a different way. The C++ standard doesn't even mandate that virtual tables be used at all, much … | |
Re: [B]>Where's the $?[/B] Where? Everywhere. You'll find that wherever you work, the salaries have a tendency to correspond to the cost of living. If the salaries are lower, so are the costs of living in that area. As long as you're a top tier IT dude, you'll get top tier … | |
Re: [B]>am an engineering student and took the AI course by mistake ![/B] So drop the course. You can do that, you know. | |
Re: [B]>i want to read the text that i enter in textFields on Internet explorer ....[/B] Sounds very suspicious. Can you come up with a reason why you want to do this that doesn't amount to malware? | |
Re: [B]>How would it relate to 'kernels as an abstraction layer for hardware'? [/B] The kernel talks to the hardware so that applications don't have to consider every possible hardware configuration. It would really suck to require a different build of Microsoft Word because you bought a new monitor, ne? | |
Re: [B]>Anybody?[/B] Probably not, seeing as you appear to have ignored the previous replies to the same question in another thread. We're generally hostile toward people who waste our time. p.s. Don't bump your threads. It's extremely rude and antisocial. | |
Re: In your current code you declare num_elements both in the global scope, and locally within main. When multiple variables from different scopes have the same identifier, the one from the most local scope will be used. So the num_elements in main is hiding the global num_elements. sample does indeed work … | |
Re: [B]>it won't work the way i want it[/B] So fix it. We're not the psychic friends network, here to solve all of you problems with a crystal ball and smile. You wrote the damn program (and it's very short!), so you should be able to figure out why it's not … | |
Re: [B]>whats the story.[/B] The story is that the code you posted is not valid C. You're likely relying on a compiler extension that allows nested function definitions. What compiler are you using? | |
Re: Methinks this poll is biased. You're missing a few moderators, including our illustrious super mod... | |
Re: [B]>i read that the precision of float is 6 digits and double is 10.[/B] No, the precision of float is FLT_DIG and double is DBL_DIG, where both of those macros are defined in <float.h>. [B]>but it is showing only 6 for both.[/B] Yes, that's the correct behavior. If you print … | |
Re: Your code is C++, not C. In C++ void* conversions are not implicit and require a cast. | |
Re: [B]>It seems that your function fails to check the ends of the arrays. >Please revise your code.[/B] That doesn't look like a compiler error. Did your teacher tell you this? | |
Re: Five days, huh? Maybe you aren't cut out for programming? Post your code and somebody will try to help you. | |
Re: Two replies (one from a mod), and both are horrid. You both completely missed the fact that the <string> header wasn't included, which means any use of the std::string try (qualified or no) will fail miserably. *sigh* Here is the corrected[1] code. I added the <string> header and qualified the … | |
Re: You say you want to parse HTML, but to what end? Are you writing a browser? Something to automatically check your stocks? A spider, perhaps? The answer to that question will determine the lengths you need to go to write the parser. | |
Re: Please post the error and specify which compiler you're using. Also, are you compiling as C or C++? | |
Re: Not unless you change your data structure or make certain assumptions based on the order of the array elements. But filtering one random array based on criteria from another random array, no, you're pretty much stuck with the brute force naive methods. | |
Re: [B]>But, don't get what it means to initialize to T()?[/B] T() is the default constructor for the type T. | |
Re: [B]>With that in mind generating a random character is easy: >char randomUpperCase= 'A' + rand() % 26; >char randomLowerCase= 'a' + rand() % 26;[/B] Easy if you ignore the portability issue. The only characters that are guaranteed to be consecutive in C++ are the decimal digits '0'-'9'. Your code in … | |
Re: [B]>Is there any suggestion for improvement[/B] Yes, I can recommend improvements: [B]>scanf("%d",&n);[/B] Always check your input functions for success. Especially with user input, and more especially with functions that are being used inappropriately (like scanf for user input), you need to take care that it read what you wanted. You … | |
Re: [B]>int nulls=atoi(argv[2]); >int arry[nulls];[/B] Nope, sorry. C++ doesn't allow an array size that isn't a compile-time constant. [B]>const int nulls=atoi(argv[2]); >int arry[nulls];[/B] Bzzt! Wrong! nulls is still not a compile-time constant despite being qualified as const. This is because to be truly compile-time, the variable needs to be qualified as … | |
Re: I'm very much not interested in reading that mess of unformatted code, so I'll simply give you two links that might help: [URL="http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_avl.aspx"]AVL Tree Tutorial[/URL] [URL="http://www.eternallyconfuzzled.com/libs/jsw_avltree.zip"]AVL Tree Implementation[/URL] | |
Re: [B]inline[/B]: Similar to C++'s inline keyword. It gives you the option of telling the compiler that you want inline expansion rather than real function object code. Inline functions are a safer and easier to use alternative to function macros: [code] static inline swap ( int *a, int *b ) { … | |
Re: And what was your answer? We're not here to do your homework for you. p.s. Use code tags for code. It's not like Daniweb doesn't slap you in the face with instructions each time you post. p.p.s. At least this question is solvable, unlike your other one. | |
Re: [B]>I cannot change the main function[/B] Sucks for you then, because the error is in main and can't be fixed from findMax. You have an uninitialized pointer. [B]>pToMax = &arr[0]; >//should be >pToMax = &arr;[/B] No, that changes the the meaning of the expression and introduces a type mismatch. It … | |
Re: No code, no help. This is obviously homework, so you need to read Daniweb's rules one more time before posting again. | |
Re: [B]>Actually it does compile. [/B] TYPE is never defined, which causes a relatively large number of errors regardless of which compiler one uses. You also rely on non-portable behavior that breaks two of my compilers (I suppose TYPE is also a compiler extension, since you claim the code compiles on … | |
Re: <psychic_debugging> I'm willing to bet that you copied the code from that site without adding the necessary scaffolding. For example, executable (as opposed to declarative) code needs to be wrapped in a function: [code] #include <windows.h> // Assuming this for Sleep #include "libwmp3.h" int main() { /* create class instance … | |
Re: [B]>One way I would approach this, is not to worry about templating the >function at all until you get a function that does what you want it to do.[/B] Good advice. This is especially useful when writing large template classes due to the "feature" of not instantiating templates that aren't … | |
Re: Being busy and lack of interest conspire to keep me away. Rest assured, when(if) I return full force, you can look forward to old school Narue replies. | |
Re: [B]>the compiler is actually giving an error though -- "invalid operands to binary *" [/B] The compiler is actually right. Multiplication for pointers is nonsensical. Why don't you tell us what you're trying to do and we can tell you how to go about it, because you clearly need someone … | |
Re: [B]>How can they possibly do this, how would you get it to compile itself?[/B] [LIST=1] [*]Write an initial compiler for your new language in an existing language (ex. the first Pascal compiler was written in Fortran). [*]Write a bootstrapping compiler for your new langauge with that initial compiler. [*]Your new … | |
Re: Use nombres the same way in edadMedia as you did in main (ie. as an array). However, I strongly recommend that you pass the size of the array as well so that you can avoid bogus indexes in edadMedia. A few notes: [B]>printf("Accediendo a %s:\n", filename); >FILE *file = fopen(filename, … | |
Re: [B]>array1[]; >array2[];[/B] A type and a size are both required. [B]>length;[/B] A type is required. [B]>name1.array1[4] = {3,0,7}; >name1.array2[4] = {0,15,0,-4};[/B] Alas, arrays can't be assigned to like that. You need to do this during the initialization of the structure instance, or manually assign to each element: [code] #include <stdio.h> … | |
Re: If you want to be able to roll back changes, store the contents of the vector in a backup vector before making the changes. Alternatively, you could reverse your algorithm to obtain the original values, but the backup vector is easier and faster (at the cost of extra memory usage). | |
Re: If you know how to use arrays, and you know how to use FILE pointers, you know how to use arrays of FILE pointers. There's really nothing tricky about it except for the number of files you can have open at any given time. The FOPEN_MAX macro in stdio.h tells … | |
Re: Your polynomial class has a pointer member and a destructor, but no user-defined copy constructor. Sounds like a one-way ticket to the exact error you're describing. | |
Re: [B]>I'm not sure how to get the vowels to show up in Case A. [/B] The problem isn't the pointer, it's the fact that you're returning a pointer to a local array. When the function returns, the memory for that array is reclaimed. In other words, it's not yours anymore. … | |
Re: Obviously you can't overload the [][] operator because no such operator exists. What you need to do for your MatrixClass class is overload the [] operator to return another type that also overloads the [] operator. | |
Re: [B]>You can also do this: <snip conio.h crap>[/B] You [i]can[/i] do that...but don't teach it to others. Using conio.h is like bumping uglies with a fat chick. A lot of guys might do it, but they don't talk about it. Such is the way with bad programming practices. | |
Re: [B]>if the char "c" lies between 48 and 57 then print it , or else ignore[/B] Congratulations! You've introduced a completely unnecessary dependency in your program due to sheer ignorance and reduced the readability of your program at the same time. Double whammies like that are rare. Compare and contrast: … | |
Re: The names of your variables go away after compilation, so you can't query them at runtime. Instead of trying to do something magical, why not store a name in your structure and use that? Of course, your program is missing a lot of required logic to make this work. Here's … | |
Re: [B]>pBuffer[26627664] = '\0';[/B] You've got an off-by-one error. Do try to remember that array indexing in C is based on an offset, not an item count. pBuffer[0] is the first item, so pBuffer[N-1] is the last item, and pBuffer[N] is an overflow error. [B]>Char* pBuffer = (Char*)new BYTE[26627664];[/B] How are … | |
Re: [B]>then all you have to do is use a for loop, start from >strlen(str)-1 , to >= 0 and print out at index i. [/B] It's not that simple. Read the question more carefully. What the OP wants is word reversal within a sentence, where a word is a sequence … | |
Re: [B]>what is the difference between these two ?[/B] The only difference is in the details. Assuming your "factory design implementation" is some other variant of the factory pattern from a factory function, you've simply described two ways of doing the same thing. | |
Re: [B]>I understand for quick solutions you would follow AncientDragon's sage advice.[/B] Actually, AD's advice is ideal: Student: "How do I use printf with templates in C++?" Teacher: "Don't use printf." The only reason the OP is using printf is because he's new to C++ and used to C. Giving a … | |
Re: [B]>Set UserInfo = LastName = “ , “ + Birthdate [/B] My brain has trouble parsing this line. Perhaps you meant: [code] Set UserInfo = LastName + “ , “ + Birthdate [/code] | |
Re: Typically you pass in any object derived from istream or ostream (such as cin, cout, any fstream object, any stringstream object, etc...). Equally typically, the return value is used to get the result of the operation: [code] if (!foo.read(std::cin)) panic(); foo.print(std::cout); [/code] |
The End.