to access a member in an array, you would use:
array[ 4 ]
to access the same item with pointer notation you could say:
*( array + 4 )
User Profile
Collapse
-
there is an output set mode function that works for floats as opposed to doubles.
showpoint is the function, and it combines with setprecision. as in:
cout << setprecision (3) << showpoint << 1.00;
setprecision requires #include <iomanip>, and showpoint just requires #include <iostream>Leave a comment:
-
no, the whitespace does not matter with regard to the pointer declaration.
terms *express
is the same as
terms* expressLeave a comment:
-
You're learning file I/O and haven't even learned loops yet? That seems a little odd, but it's been a while for me. Anyone else think that's weird?Leave a comment:
-
-
You would need to create a default constructor that takes no arguments, OR you could put default arguments into the constructor you do have, i.e.
in your header file
surf::surf ( int = 0, int = 0 );
then in the .cpp file
surf::surf ( int x, int y ) {
// set your class variables to these values
}
what happens is that you can call the constructor with two variables,...Leave a comment:
-
Make your matrix a class with members that specify the dimensions...Leave a comment:
-
-
Microsoft Visual C++ Express 2005 is available for free from their website, and it is a complete itengrated development environment. That means it includes the text editor as well as all the compile a debug tools built right into the same package. I know some people hate Microsoft, but it's free and it works well.Leave a comment:
-
Are you asking us to do the entire project for you? It's one thing to ask for help when you're up against a wall and you have a bug you can't find, but you sound like you haven't even tried anything yet and want someone to write the whole thing for you...Leave a comment:
-
by overloading the '<<' function, you're teaching the compiler how to output an entire Queue object to the screen. So, somewhere in your printQ function, you just need this line:
cout << theQ;
When the compiler sees this, it generates the following function call:
operator<< ( cout, theQ );
Inside the overloaded '<<' is where you put all the hard work of walking through...Leave a comment:
-
I got my feet wet in high school with Pascal, and it was a good intro to the basic concepts of control structures, logic, algorithms, functions, etc. In college they threw us right into C++ and I thought it was fine.
I do agree with the guy who said "best" is a relative term, though, so it depends. I'm not in the industry, so it's hard to say in that regard, but I will add this: if you're just starting to learn, I don't...Leave a comment:
-
In the function parameters list you listed the function name PrintQ. That should actually be a type (int, char, or in your case Queue). Then follow it with & theQ. Also, if you want to be able to use 'cout' in the normal way ( cout << theQ[c] ), your overloaded function cannot be a member function of the queue object, so unless the items you are printing are public members, the overloaded '<<' operator will not have direct access...Leave a comment:
-
Is that because of the 'void'?
In my first programming class (years back) they taught us to use void. It wasn't until several semesters later that I heard somewhere along the way that 'int' is considered better. Can't say I recall the reason though, but I'd be curious to hear if you have an explanation.
Thanks,Leave a comment:
-
Q1: ( numberOfPrizes % numberOfPartici pants == 0 );
Q2: ( widthOfBox % widthOfBook != 0 );...Leave a comment:
-
I think we need more info than that. Sorry. Be glad to help if you give a little bit more guidance.Leave a comment:
-
What you do, since it's a linked list, is you find the last item in the linked list (LL) that would come before the new entry. Now, in a LL, each item should have a pointer (or some other method of reference) to the next item in the LL (call this pointer NEXT). Also, for explanation's sake, let's call your three items A, B and N (for new).
A and B are already in the LL, and A points to B as the next item in the LL. Create N (the...Leave a comment:
-
I'd just do a simple for loop;
First, create a temporary variable of whatever the type is for the list of items and initialize it to 0, or some appropriate value. Then, starting at the first list element,
Temp = Temp + ListItem[index];
or just Temp += ListItem[index];
Once the for loop is finished, exit from the function Summation by returning the value of the temp variable you created.
...Leave a comment:
-
You CAN make just about anything a constant. But if you did that, you would have to initialize the pointers when you created them, and could never dynamically allocate more memory.
This could be useful, though, because a pointer uses much less memory (potentially) than the object to which it points. That way, you could save yourself (potentially, again) A LOT of over head from passing arguments to functions.
For instance,...Leave a comment:
-
Doesn't do much of anything productive, that's for sure. All it will actually do is continue allocating new memory until it has used up all that the system has available, at which point is will throw an exception and terminate program execution.
It's not quite an infinite loop, in that it will finally exit when the system is no longer able to allocate more memory to the pointer 'p'. At that point, though, it will probably break out...Leave a comment:
No activity results to display
Show More
Leave a comment: