- Strength to Increase Rep
- +6
- Strength to Decrease Rep
- -1
- Upvotes Received
- 48
- Posts with Upvotes
- 44
- Upvoting Members
- 34
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
- PC Specs
- Dell Inspiron 1525, Ubuntu GNOME 13.10
Re: > Does anyone know if ubuntu is good for programming? It depends on what you're programming. For the most part, programming something in Linux is simpler than programming it in Windows, just because libraries are handled by a package manager rather than having to go through the tedious process of … | |
Re: [quote]I really do like programming, it's just that the problem solving part is difficult for me.[/quote]I have devastating news for you. [quote]I forgot to mention that I'm relatively new to C++, and I have no idea what most of that means :p[/quote]Don't fret. I've been using C++ for five years … | |
Re: > Should I get ubuntu on my mac? Is there a particular task that you want to accomplish on Ubuntu that you can't do on your current OS? It may not be worth the effort if you can do everything perfectly fine on your Mac as it is. > when … | |
Re: Because you're essentially looking at the least significant bit first, you're printing them first, and as a result, the number is being printed backwards. A couple of notes here. The line `rem = rem%10` more than likely does not do anything because the line `rem=quotient%2` guarantees that `rem` will either … | |
Re: First code: You're calling `mainPage()` as if it belongs to the global scope. The way you've written your code, though, it actually belongs to your class `foo`. My best bet is, because of the context, it assumes you're declaring an implicitly-`int` function called `mainPage()` inside of both `minus()` and `add()`, … | |
Re: Ancient Dragon: Are you sure you're compiling as C and not C++? There are no VLAs in C++. | |
Re: You're erasing elements by position rather than by value. Once you start erasing values like that, you can't expect `v[number]` to be equal to `number` anymore. A better solution to this problem would be to have an array of `bool` keep track of which numbers can be prime, and which … | |
Re: You would make the fuction virtual, which allows you to override the behavior of a function when defining the child class. It should be as simple as changing `void set_dimensions()` as `virtual void set_dimensions()` in your `shape2D` class, and then rewriting `shape3D::set_dimensions()` to accept all three dimensions. There may also … | |
Re: I would recommend [icode]enum[/icode] in this case because that's exactly what they're there for. | |
Re: When you pipe two programs together via the shell, it actually just pumps the `stdout` of the program on the left into the `stdin` of the program on the right. There is no real need for calling `pipe()` inside your program in this case. For example, if I wrote the … | |
Re: main.c:7:6: error: 'i' undeclared (first use in this function) main.c:7:13: error: 'y' undeclared (first use in this function) main.c:9:3: error: 'x' undeclared (first use in this function) main.c:11:2: error: 't' undeclared (first use in this function) | |
Re: Is there any particular reason you're using `for_each` when you already have C++11's range based `for` loops available? Is it part of an assignment that your `add()` function has to exist? The following would be easier. for(auto& i : vec) i += 2; for(auto i : vec) cout << i; | |
Re: Another way to print the values pointed to by the vector is to use C++11's new range-based `for` loops (if you have an up-to-date compiler). This way, you don't even have to declare your own iterator. for(auto ptr : ptrList) cout << *ptr << endl; | |
Re: > Is this memory efficient to split things up for developer "ease-of-use"? Even if it wasn't, it doesn't matter. Code maintainability and readability is a lot more important than shaving off a few bytes here and there. Your time as a developer is a worth more money than a few … | |
Re: > That's quite a bit of difference, especially if there are thousands of nodes in the linked list. But don't compilers typically like to pad structs so that they are aligned a certain way (Like making the size a multiple of four)? Assuming an environment where `sizeof(int) == 4` and … | |
Re: What exactly is Vvariant supposed to be? It's impossible to get the value of a `void*` (without typecasting it first), and it's dangerous to dereference a pointer that is `NULL`. | |
Re: You would be right. Arrays decay into pointers when you use them in a name context. | |
Re: He means this sounds like a homework assignment, and we don't do those for people. You actually have to show some sort of an effort towards solving the problem. | |
Re: Because you're recursively calling `printtree()`, this means you're also calling `fopen()` over and over again. As a result, you're overwriting the file every time you print something to it. (The file handle is also not getting closed properly. I would suggest opening the file outside of `printtree()`, and modifying the … | |
Re: You're using `strlen()` incorrectly. It doesn't take an `int`, it takes a `const char*`. The way you have your code written, it might be easier to simply count, one by one, how many characters there are by counting them as you print them, using `textLength` as a counter. if(file) { … | |
Re: You're spoonfeeding the answer to what is clearly a homework assignment to somebody who doesn't want to do any of the programming themselves. This is the reason so many people can get CS degrees without even knowing how to do FizzBuzz. I hope his professor is at least smart enough … | |
Re: NathanOliver: There is actually a `getline()` for `std::string` as well. `istream& getline (istream& is, string& str);` | |
Re: Are you doing this in an initialization context? Because if you do something like the following declaration: int *ptr = 12; It probably will not error, but instead make `ptr` point to the (probably invalid) memory location of 12. Otherwise, I'm absolutely baffled that no error occured. | |
Re: jwenting: In India, schools have unfortunately standardized around Turbo C/C++. | |
Re: As a general rule of thumb, if your program can be "optimized" by changing one little operator like that, then the compiler will likely do it for you. That being said, the short-circuiting behavior mentioned by deceptikon is important to note. Using the `&&` operator ensures that unnecessary checks are … | |
Re: Your usage of one-letter variable names, which are all declared at the very top of your `main()` function, has your program nearly impossible to read, let alone debug. You need to provide descriptive variable names if you want your stuff to be self explanatory. Do you seriously think it's good … | |
Re: > PS: I see that a lot of people are already familiar with C++11 to the point that they don't think about it when they use its features. Is it now considered 'best practice' to use the new features? I am mainly concerned due to the lack of universal support … | |
Re: > At lines 33 and 38 your formal parameters are floats but you call the function using doubles - you can fix this by changing floats to doubles ( ex: 5.5 to 5.5f ) or simply change the parameter's type from the methods's header. Doubles are automatically converted to floats … | |
Re: You've got the right idea, but overloading really isn't polymorphism at all. | |
Re: > The while statement is a loop that contininues to execute until some condition is met. I think you meant to say a while statement is a loop that continues to execute *while* some condition is met. |