Forum: C++ 16 Hours Ago |
| Replies: 2 Views: 69 >current = new Node ; // creates a new node
This uses the default constructor. |
Forum: C++ 17 Hours Ago |
| Replies: 3 Views: 83 >So, just pass "1" instead of "heap[1]?"
Yep. Otherwise you're using whatever value is currently at heap[1] as an index for the swap, which is only likely to be safe if all of the values in the heap... |
Forum: C++ 17 Hours Ago |
| Replies: 3 Views: 83 >Adjust(heap, heap[1], j);
At a glance of the code, I really don't think heap[1] is an appropriate index in this call. It should probably be 1. ;) |
Forum: C++ 23 Hours Ago |
| Replies: 7 Views: 233 >In this style every one can understand easily!!
You're absolutely right. Everyone can easily understand that you're a horrible programmer whose advice should be ignored. |
Forum: C++ 1 Day Ago |
| Replies: 2 Views: 98 >it is possible?
Have you tried it? A lot of your questions can be tested with a compiler and a small bit of code. |
Forum: C++ 1 Day Ago |
| Replies: 8 Views: 180 Basics of Programming (by Narue):
Find a problem to solve.
Understand the problem.
Figure out a solution to the problem.
Write code to implement the solution.
Debug the code you wrote.
... |
Forum: C++ 1 Day Ago |
| Replies: 7 Views: 151 >I belive three, for(Iterator = something ; while-condition; do something to limit the loop ) ?
That's correct. Now take a look at your code and see if it matches what you just described. |
Forum: C++ 1 Day Ago |
| Replies: 7 Views: 151 >Lines 124 and 132 contain the same two errors.
I'll answer your question with another question: How many clauses does a for loop have?
p.s. You also need to include the <string> header. |
Forum: C++ 1 Day Ago |
| Replies: 3 Views: 105 >And the syntax is always
>double get_value() const;
Yes.
>or can be
>const double get_value() const;
That's different. The leading const is applied to the return type and means you want to... |
Forum: C++ 1 Day Ago |
| Replies: 3 Views: 105 Didn't we already go over this with you? If you want to call a member function through a const object, the member function should be qualified as const too:
#include<iostream>
#include<math.h>
... |
Forum: C++ 1 Day Ago |
| Replies: 11 Views: 238 >I really can't see why you'd think that.
All I can do is explain myself. If you still don't understand, that's not really my problem.
>I wasn't clinging to my solution at all
That's BS. Twice... |
Forum: C++ 1 Day Ago |
| Replies: 5 Views: 125 >Sry but is it easy for you to make that example for my case up there?
Yes, it's trivial. That's why I left it for you to do. |
Forum: C++ 1 Day Ago |
| Replies: 2 Views: 110 Sadly, constraints are not a part of C++, and concepts (the design for constraints) have been dropped from the next revision of the standard. However, you can fake it using static assertions and... |
Forum: C++ 1 Day Ago |
| Replies: 4 Views: 112 |
Forum: C++ 1 Day Ago |
| Replies: 5 Views: 125 By default std::sort uses an overloaded operator< for the type, but you can pass a predicate to std::sort as the third argument:
#include <algorithm>
#include <cstdlib>
#include <iostream>
... |
Forum: C++ 1 Day Ago |
| Replies: 5 Views: 133 You can specialize myclass::function based on the template parameters of myclass:
#include <iostream>
struct mystruct {};
template <class T>
class myclass
{
public: |
Forum: C++ 1 Day Ago |
| Replies: 4 Views: 112 >std::queue<std::string> prio_q;
You know the standard library has a priority_queue class too, right? |
Forum: C++ 2 Days Ago |
| Replies: 11 Views: 238 >Narue, WHY are you ranting about it?
Because I'm trying to help you, and I think ranting is the only way you'll pay attention. You should be flattered. Normally, I wouldn't bother replying to... |
Forum: C++ 2 Days Ago |
| Replies: 2 Views: 116 Did you check your handy C++ library reference? Because it's all explained there, and a more specific question than "can you tell me everything I want to know?" is likely to encourage high quality... |
Forum: C++ 2 Days Ago |
| Replies: 11 Views: 238 >Because once I press ignore, check the log file, see the record
>where the problem occurred, and fix the format, then I don't have a problem anymore.
Then you're parsing the file incorrectly. The... |
Forum: C++ 2 Days Ago |
| Replies: 11 Views: 238 >No see it's ok if it's ignored.
No, see it's not. A debug assertion doesn't mean you hit an expected runtime error condition, and it doesn't mean that your files aren't formatted the way your... |
Forum: C++ 2 Days Ago |
| Replies: 7 Views: 129 This should be a good learning experience. I'd start by manually compiling (http://www.wikihow.com/Compile-a-C-Program-Using-the-GNU-Compiler-%28GCC%29) your projects, then later you can move into... |
Forum: C++ 2 Days Ago |
| Replies: 11 Views: 238 >is there a way to make it ignore automatically? Without the message box appearing?
Yes, fix the error that causes the message in the first place. Silencing an error doesn't make the error go away,... |
Forum: C++ 3 Days Ago |
| Replies: 3 Views: 118 >1. Line #8 works (at least my compiler doesn't comply), but line #12 is not allowed. Why?
Because the types are incompatible. It's legal to add a const qualifier as such:
int *p = 0;
const int... |
Forum: C++ 5 Days Ago |
| Replies: 6 Views: 157 >I am using Visual C++
More specifically, it looks like you're using C++/CLI. I don't recommend mixing standard C++ libraries (such as ifstream) and .NET libraries (like System::String). It's more... |
Forum: C++ 5 Days Ago |
| Replies: 6 Views: 157 std::string name;
// Get the name...
std::ifstream in ( ( name + ".txt" ).c_str() ); |
Forum: C++ 5 Days Ago |
| Replies: 4 Views: 169 >but specifically pointers to Foo objects for the > operator,
>would that really be a bad idea you think?
I don't really see how that changes anything. Granted you can't do it, so this is... |
Forum: C++ 5 Days Ago |
| Replies: 14 Views: 244 >What does it mean "rvalue" ?
The details are kind of murky now, but originally lvalue meant anything that could be on the left hand side of an assignment expression, and rvalue meant anything that... |
Forum: C++ 5 Days Ago |
| Replies: 3 Views: 155 I can't do anything about your eyesight. But it does show an example of how to define the function under the heading "Compound Assignment Operators += -= *=". |
Forum: C++ 5 Days Ago |
| Replies: 14 Views: 244 >Because if it was const double& then you can't just say
>realObject + 5, because 5 is a literal and we can't have a refrence to it.
Fortunately, binding an rvalue to a const reference is legal. I... |
Forum: C++ 5 Days Ago |
| Replies: 11 Views: 210 >I do not care about memory just the speed!
Memory usage can affect speed. If you use too much memory you can cross cache lines, or even cause thrashing. However, caring about something when there's... |
Forum: C++ 5 Days Ago |
| Replies: 9 Views: 145 >So the question is how big is a pointer?
>tipically it is greater than a double or not?
It's implementation-defined, but easy to test:
#include <iostream>
int main()
{
... |
Forum: C++ 5 Days Ago |
| Replies: 9 Views: 145 >So its definitelly better to pass everything by reference not
>just classes but builtin type like a simple double also?
Not necessarily. A reference is likely to take up more memory than a char... |
Forum: C++ 5 Days Ago |
| Replies: 11 Views: 210 I wouldn't bother worrying too much about speed unless you can prove that your code is slow enough to justify optimizing. |
Forum: C++ 5 Days Ago |
| Replies: 3 Views: 155 >I cannot find on the web.
You didn't look very hard, did you? This (http://www.cs.caltech.edu/courses/cs11/material/cpp/donnie/cpp-ops.html) is the first hit from google that I got using keywords... |
Forum: C++ 5 Days Ago |
| Replies: 11 Views: 237 >plz dont post in my thread unless you have tried to help
I tried to help and you made your stance on willful ignorance and biting the hand that feeds you quite clear. You might as well just go... |
Forum: C++ 5 Days Ago |
| Replies: 9 Views: 145 >Therfore the previous one is more preferable?
Passing objects by const reference is preferable because it's pretty much always more efficient than passing by value. The reference generally takes up... |
Forum: C++ 5 Days Ago |
| Replies: 14 Views: 244 >Its good to see that you are a human as well
You should see me typing boilerplate code:
itn doh!
^H^H
int amin what the?!
^H^H^H^H
int mina crap! |
Forum: C++ 5 Days Ago |
| Replies: 11 Views: 237 >i just want to finish this assignment
What will you do on the next assignment? And the next? And the one after that? The class will get harder and harder, and you'll not get any less ignorant.... |
Forum: C++ 5 Days Ago |
| Replies: 14 Views: 244 >If you want to do it that way, you will need to make that function a friend function.
Yes, thank you for the correction. I'll blame a disconnect between my brain thinking friend and my fingers... |