6,741 Posted Topics
![]() | Re: Looks like a pigeonhole sort to me. |
Re: [B]>Basically what is the system level difference between language C and C++ ?[/B] There are probably more systems with a C implementation than a C++ implementation, but aside from that the difference is nil. [B]>well the main difference is that c is a procedural >language while c++ is an object … | |
Re: [code] class Example { int x; }; [/code] Example::x is a private data member. This means that only friends and the Example class itself can access it. This is good practice, data members should be private. But let's say you still want to give users of the class restricted access. … | |
Re: [B]>Can you predict what the answer will be?[/B] I can certainly try. [B]>Now run it, were you right?[/B] Yup. | |
Re: Somen noodles, the easiest breakfast you'll ever cook. 1 bundle of somen 6 cups of water 1 tablespoon of salt Boil the water, pour in the salt, toss in the somen, cook on medium heat for 3 minutes. It's good plain or with all manner of sauces and garnish. :) | |
![]() | Re: >Then what is the point to use pointer and new operator to declare the array in the first case? Because the second case is ill-formed and thus, illegal in C++. Array sizes in C++ must be [B]constant[/B] integral values. If it works when you try it then that's because your … |
Re: I suspect you're compiling your C code as C++. That's not recommended unless you really know what you're doing. Anyway: [B]>#include <malloc.h>[/B] <malloc.h> is archaic and non-standard. Use <stdlib.h> instead. [code] /* Wrong */ struct strs { char x; }; typedef struct str strs; [/code] Notice that your typedef is … | |
Re: [B]>So in essence, what is undefined in the Standard becomes >defined in the context of a particular compiler.[/B] That rather goes without saying, but doesn't change anything. The result can still be unpredictable, and it's certainly not portable. [B]>Doesn't it blur the difference between the two things, >when the implementation … | |
Re: EOF isn't a character from the stream. | |
Re: [B]>who can answer thi question??[/B] You can. We can too, but [I]won't[/I], because we don't help students cheat on their homework. | |
Re: [B]>I know that ++a is faster than a++ because a++ has to first store >the previous value of a at some temporary location and then >increment a and then return the saved value, whereas ++a simply >increments a and returns the pointer to the incremented value.[/B] That's a reasonable analysis, … | |
Re: [B]>I'm wondering if I'm duplicating this class by doing the following.[/B] I'm not sure what you mean by "duplicating this class". [ICODE]point[/ICODE] will point to an object that's copy constructed using sc as the argument. Whether that's a good thing or not depends on how SimpleExample is implemented. It could … | |
Re: shock1, any book on C++ will answer these questions for you. Please don't spam the board before searching for your own answers. | |
Re: Assuming you can't just allocate the whole thing after getting the rows, it looks like you're on the same track for what I would consider doing. I'd create an array of three dynamic arrays at compile time, then allocate memory accordingly and use the array as if the rows were … | |
Re: [B]>please suggest me a way to solve this problem[/B] It's easy to break the world down into comments, identifiers (which includes keywords), operators, and literals. From there you can simply check for existence in your keyword and operator lists to find matches. A C compiler will use a greedy tokenizing … | |
Re: [B]>can i use undef for a function like - macro, by just specifying the >name of the macro with out specifying the argument list as written in line 8.[/B] Yes, though not exactly like line 8 because preprocessor directives don't end with a semicolon. To answer your specific "doubt", the … | |
Re: The program requirements say all that needs to be said: [quote] Please solve it on your own/submit your own solution. [/quote] We don't help cheaters cheat. | |
Re: Think of console input as a two tier operation. At the top level is the shell (the console itself), which talks to the keyboard driver and buffers characters typed by the user. When the user signals the end of input (usually in the form of a newline), the shell stops … | |
Re: [B]>Well then be more vocal about which features you use and how you use them.[/B] Do you want a weekly status report about how we use the site? When you change things in a seemingly arbitrary way without asking for specific feedback from us, it's hard to give you the … | |
Re: [B]>Is saving my files as .cpp the problem?[/B] If you're trying to compile C as C++ then yes, that could be a problem. There are subtle differences between the two languages such that the C subset of C++ and actual C aren't perfect matches. In your project properties->configuration properties->C/C++->Advanced, you … | |
Re: [B]>why sizeof does not consider name of the array >as some address and give pointer size bytes.[/B] Because the conversion from array to pointer only occurs in a value context. The operand of sizeof is being used in an object context, so the conversion doesn't happen. There are three object … | |
Re: [B]>What does BIOS do on modern PCs after the operating system is loaded and running?[/B] A whole lot of nothing. The whole point of the BIOS is to put the system into a state where the OS can be loaded. After the OS is loaded, it takes over control of … | |
Re: [B]>Sorry for the unclarity[/B] Here's a brute force example program that does what I think you're asking for. It might help the requirements become more clear for the participants (assuming I understand them ;)): [code] #include <functional> #include <iostream> #include <numeric> #include <string> #include <vector> class listall { const std::vector<int>& … | |
Re: [B]>Any suggestions?[/B] Sure. Change [ICODE]getMap(&map)[/ICODE] to [ICODE]getMap(map)[/ICODE]. You're adding an unnecessary level of indirection, and the compiler doesn't like it. p.s. For the record, [ICODE]while(!myfile.eof())[/ICODE] is a bad idea. [URL="http://www.gidnetwork.com/b-58.html"]This[/URL] describes the equivalent problem in C. | |
![]() | Re: [B]>Are you saying the other 85% should be on my hit list?[/B] [sarcasm] Of course not. That's silly. You should put everyone who doesn't bow down and kiss your feet on the [I]ignore list[/I]! Stupid retarded pleebs who don't know their place deserve it. I mean really, don't they realize … ![]() |
Re: [B]>superclass (or parent class if you will) >subclass (or child class if you will)[/B] It's generally better to use the established terminology rather than equivalent terminology from another language. The C++ standard uses "base" for superclass and "derived" for subclass. Superclass and subclass have traditionally been very confusing, though I'll … | |
Re: [B]>But is it worthwhile learning C if I already know python?[/B] Personally I think everyone can benefit from learning C, but your question suggests that you don't see any point in it. If you're a hobbyist, don't force yourself to learn something you don't really want to. | |
Re: [B]>Yep, It worked. No syntax errors.[/B] You'll find that people are more effective at helping you if you don't lie to them: [quote] [B]You[/B]: Here's my code, it compiles but gives me a warning "[I]<blah blah>[/I]". [B]Us[/B]: That's funny, because the code you posted isn't and never has been legal … | |
Re: [B]>whch progrms u need???????? [/B] If you do this guy's homework for him, I'll be most displeased. :@ [B]>our teacher just gave us two days...[/B] Which is plenty of time. Stop acting like a loser and do your own damn work. We'll help you if you have specific questions, but … | |
Re: Don't use preprocessor macros unless you know how the preprocessor works. It's all to easy to forget that it's [b]textual replacement before anything else[/b]. So this: [code] #define SIZE 9 BTREE makeTree(int a[], int i, int SIZE); [/code] Becomes this: [code] #define SIZE 9 BTREE makeTree(int a[], int i, int … | |
Re: [B]>What is the significance of the following format specifiers:[/B] Relatively low, but they come in handy occasionally. | |
Re: [B]>I'm already taking an intro to C class[/B] Very cool. I'm a big proponent of learning C well, even if you never plan on using it. [B]>is it wise to take these two classes at the same time? [/B] It's extremely unlikely that the C++ course will be taught "properly", … | |
Re: [B]>is this possible?[/B] Is this a troll? Or a bad joke? Of course it's possible, as are most things that noobs use the "is it possible?" question to ask about. | |
Re: [B]>what is the complexity of searching an item in hashtable in average case performance[/B] Amortized O(1). While an individual search might be more expensive, in toto the performance is constant. This is all assuming the hash table is properly implemented, of course. | |
Re: [B]>How would you do that ?[/B] Look up template specialization. You write a generic template that handles the majority of types, then specialize on the ones that don't support the same operations. In your example, the template for C-style strings would be a specialization because C-style strings have different semantics … | |
Re: [B]>I am learning the OOP recently and i have a few questions to ask[/B] I wouldn't list operator overloading or templates as features of OOP. In fact, templates are how C++ supports a somewhat different paradigm from OOP: generic programming. [B]>1) When should i use operator overloading? >2) When should … | |
Re: [B]>goto /*line*/ 18;[/B] goto is restricted to a single function, you can't jump between functions with it. [B]>conio.h is an older c header file and is deprecated in C++...[/B] Please don't use deprecated to mean anything except "standard, but not recommended because it might not be standard in the next … | |
Re: >but i tried it on the postal code anyways. it still skips it You fixed the wrong problem. Here, watch: [code] [COLOR="red"]You're typing a last name, say "smith". But you finish by hitting the Enter key. Thus the string is really "smith\n". scanf doesn't read the '\n', so it stays … | |
Re: The header contains declarations and is included in multiple places because declarations can be duplicated. Then you have one implementation file that has the definitions: [code] /* globals.h */ extern int glob; extern int foo ( void ); [/code] [code] /* globals.c */ #include "globals.h" int glob = 0; int … | |
Re: [B]>there some that dont have answer which you know please do tell..[/B] No. We'll tell you if your answers are correct or not, but we're not doing your homework for you. [B]>Write a brief answer to the following items. [/B] No. [i]You[/i] write a brief answer and we'll tell you … | |
Re: [B]>If u r programming in visual studio c++[/B] I'm not programming in Visual C++ right now, so I guess I won't share my code with you. :icon_rolleyes: [B]>I WILL ALSO SHARE MINE.[/B] Quite frankly, I'm not sure your code will be worth reading. But I can't verify that because I … | |
Re: [B]>Why is this producing an error?[/B] Stream objects aren't copyable at the object level. As jonsca said, you need to pass a reference to the ifstream. | |
Re: item and rtItem aren't nodes, they're the actual keys. You compare them like so: [code] if ( item == rtItem ) [/code] Your algorithm, however, is broken. It won't set equal to the correct value in all cases because you reset it to true. You need to consider more cases … | |
Re: [B]>I know I'm supposed to use new and delete, but I really need to use realloc[/B] malloc/calloc, realloc, and free don't fit well at all with objects of a class type. You really should forget they exist unless you [i]really[/i] know what you're doing. Fortunately, realloc can be simulated in … | |
Re: Check the class of whatever aPort is to see if it has a non-blocking read, or some way to query the port for incoming data. If not, you might want to look into spawning a separate process or thread for inputting data. At least that way the whole program won't … | |
Re: All you're doing with the divide and conquer is breaking up the list into smaller lists, then putting the sorted smaller lists back together. This breakdown and rebuilding is an O(logn) operation: [code=text] 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 … | |
Re: [B]>In most, if not all OSes; if a program's main function returns an int, 0 >indicates that program execution ended normally. >Any other value indicates that the program execution ended >abnormally. In other words an error occurred.[/B] That's required behavior for a C++ implementation. It has nothing to do with … | |
Re: [B]>I tried using delete[/B] That only marks the object as ready for garbage collection. It doesn't actually release anything until the garbage collector runs on the same generation. Even when the garbage collector runs, that doesn't mean your process' footprint will go down. The memory might remain allocated for faster … | |
Re: C doesn't support function overloading, but because an added dimension or level of indirection constitutes a different type, you can do what you want in C++ (more or less). | |
Re: The time function comes from the <ctime> header (failure to include it is probably your error), and keep in mind that everything in the c* headers should be in the std namespace: [code] #include <cstdlib> #include <ctime> int main() { std::srand ( (unsigned)std::time ( 0 ) ); } [/code] Though … |
The End.