Forum: C++ Apr 18th, 2009 |
| Replies: 4 Views: 442 Is it a Windows handle, the one in windows.h? It's not an initializer, it's what int and char are: a type.
If it's a window handle, it's basically as specific as a pointer. A pointer used by... |
Forum: C++ Apr 18th, 2009 |
| Replies: 3 Views: 300 You can look all that info up in a STL List reference, as the one found here:
http://www.cplusplus.com/reference/stl/list/
See the "STL Algorithms" for sorting data inside STL containers. |
Forum: C++ Apr 17th, 2009 |
| Replies: 13 Views: 684 Erm. I guess it can be compile in MSVC++. You can try to install MSVC++ Express and grab the platform SDK. Google is your friend. Can anybody else compile this code? |
Forum: C++ Apr 16th, 2009 |
| Replies: 7 Views: 437 Example of inheritance using virtual functions:
#include <iostream>
using namespace std;
class base {
public:
virtual void func(){
cout << "First level: Base class" << endl;... |
Forum: C++ Apr 16th, 2009 |
| Replies: 7 Views: 437 class Client
{
public:
string name;
Menu order;
int table_number;
string type;
double bill;
Client(void) |
Forum: C++ Apr 16th, 2009 |
| Replies: 29 Views: 1,400 Errr, ignore that last part. Sometimes I'm unclear.
Student student;
for(int subject = 0; subject < 4; subject++){
string code;
int cu;
char pass_or_fail;
inFile >> code;
... |
Forum: C++ Apr 16th, 2009 |
| Replies: 29 Views: 1,400 No, student already has 4 subjects: use those.
Student::Subjects::setVar(); |
Forum: C++ Apr 16th, 2009 |
| Replies: 29 Views: 1,400 That sucks. But still, just loop the student array then, one time for input, one time for output. So no more extra variables representing members in class Student! ;) |
Forum: C++ Apr 16th, 2009 |
| Replies: 29 Views: 1,400 You could create a function that accepts a reference to a student and outputs it's data?
void output_student(Student &stud){
//put the output code here
}
//....
int main(){
//loop each of... |
Forum: C++ Apr 16th, 2009 |
| Replies: 29 Views: 1,400 Totally wrong approach buddy. Create 4 students, read out their data.
Example code:
cout << students[0].getVar() << endl;
Kinda like that. |
Forum: C++ Apr 15th, 2009 |
| Replies: 7 Views: 364 Good luck with the assignment, don't forget about the STL! (It has a queue, of course you can't use that, but it has plenty of other useful containers and algorithms). |
Forum: C++ Apr 15th, 2009 |
| Replies: 7 Views: 364 If you're standing in queue line at the grocery shop, does the LINE look like a tree, with intersections and such, or more like an array of (possibly annoyed) customers?
I sure hope it doesn't... |
Forum: C++ Apr 15th, 2009 |
| Replies: 13 Views: 684 It doesn't compile in MinGW's GCC. Looks like MSVC code?
I'm getting these errors:
=|
sdvrp.h|18|warning: ignoring #pragma warning |
sdvrp.h|222|warning: no newline at end of file|... |
Forum: C++ Apr 15th, 2009 |
| Replies: 11 Views: 787 Oh it does you no good, but you can't really check for !file, since file would be.. something. Although it "worked", maybe by accident.
Anyway, Could you hardcode the path, "C:\test.txt", and put... |
Forum: C++ Apr 15th, 2009 |
| Replies: 11 Views: 787 Wait, doesn't the fstream constructor *always* create something? Check if file.good() is true.
Oh and, don't open it twice. In the constructor OR with fstream.open(), not both. |
Forum: C++ Apr 15th, 2009 |
| Replies: 11 Views: 787 Hurr, it might be a really stupid "error".
One time (at band camp, xD) I was trying to open a file from an app I wrote in Code::Blocks on windows. So I put that file in project/bin/debug/, but... |
Forum: C++ Apr 15th, 2009 |
| Replies: 29 Views: 1,400 Yeah, but keep in mind he didn't design the functions himself, his prof did it for him. He needs to use these functions, unaltered, I think. |
Forum: C++ Apr 15th, 2009 |
| Replies: 9 Views: 491 On my dualcore processor, 2 cores where in use and it indeed didn't give any errors as stated earlier. This is on Windows XP x64. |
Forum: C++ Apr 15th, 2009 |
| Replies: 9 Views: 491 Okay, not 100% right. Darnit. xD
I've just created a single multithreaded program and it was (a dreaded task and) crashing constantly! So I ended up creating mutexes for every "group" of shared... |
Forum: C++ Apr 15th, 2009 |
| Replies: 29 Views: 1,400 "Set pass/fail" I guess? Maybe the int is the subject indicator? Ugh, the variable names are horribly chosen. Just use that int as subject index and the char as.. P or F or something? Or grades? I... |
Forum: C++ Apr 15th, 2009 |
| Replies: 9 Views: 491 MrSpigot was 100% right, my bad. You don't need mutexes to write and read from one variable at the same time.
Tested with:
#include <iostream>
#include <windows.h>
using namespace std;
... |
Forum: C++ Apr 15th, 2009 |
| Replies: 9 Views: 491 That's wrong, almost 100% sure, couldn't make sure with google, but it's just 2 threads trying to access the same memory: doesn't matter if they read or write, both will lead to errors.
Agreed on... |
Forum: C++ Apr 15th, 2009 |
| Replies: 3 Views: 552 Sure, it looks fine, but you need to write it yourself if you want to learn C++, not somebody else.
I mean, do you know what this &*(array + k) does? (It looks rather redundant...) |
Forum: C++ Apr 14th, 2009 |
| Replies: 3 Views: 552 What doesn't work?
new doesn't set the allocated memory to 0, could that be a problem?
Be a bit more specific please. |
Forum: C++ Apr 14th, 2009 |
| Replies: 29 Views: 1,400 Haha, no, that function of course needs to know what subject to set. Change it a bit, add a comment for your prof? The other functions do have such a parameter, so maybe he forgot? |
Forum: C++ Apr 14th, 2009 |
| Replies: 29 Views: 1,400 // set the subject grade (pass or fail)
void Student::setSpf(char score,int grade)
{
}
How does that function know what subject it is supposed to work on? |
Forum: C++ Apr 13th, 2009 |
| Replies: 8 Views: 274 xD Okay, sorry. I'd suggest sqrt() nonetheless, but it doesn't really matter. |
Forum: C++ Apr 13th, 2009 |
| Replies: 8 Views: 274 He means the sqrt() function. |
Forum: C++ Apr 13th, 2009 |
| Replies: 8 Views: 274 And, not related to programming, you're squaring it, not square rooting it. |
Forum: C++ Apr 12th, 2009 |
| Replies: 29 Views: 1,400 A small addition:
Sometimes set functions do return something, and most of the time that's whether they succeeded or not.
Anyway, seeing the format, it's like this:
<name>, list(<subject>,... |
Forum: C++ Apr 12th, 2009 |
| Replies: 29 Views: 1,400 while(!inFile.eof())
{
// use getline to read entire line
getline(inFile, s);
cout << s << endl;
}
That's wrong code. eof gets set when it has read eof, so and... |
Forum: C++ Apr 11th, 2009 |
| Replies: 3 Views: 335 while(firstTry == true)
{
{
cout << "It Is Your First Try, We Will Create My Array First:\n";
updateArr(arr, size);
}
return firstTry = false; //Don't return here, hehe.
} |
Forum: C++ Apr 10th, 2009 |
| Replies: 4 Views: 437 From the reference: (http://www.libsdl.org/cgi/docwiki.cgi/SDL_keysym)
"... The unicode field is only used when UNICODE translation is enabled with SDL_EnableUNICODE. ... "
I suppose you did... |
Forum: C++ Apr 10th, 2009 |
| Replies: 4 Views: 437 Maybe make sure that conversion is going alright?
Output (char) (event.key.keysym.unicode) or something.
ASCII chars in UTF-8 might be something like, {\x00\x<ASCII-code>}, in that case,... |
Forum: C++ Feb 19th, 2009 |
| Replies: 3 Views: 973 newnode = new Node;
newnode = NULL;
Eerrrr? That's a bit of weird code. You're trying to derefence that pointer on the next line! ;) |
Forum: C++ Jan 3rd, 2009 |
| Replies: 5 Views: 315 Here are two examples I created and use as a reference, maybe they are of help:
/*
** Playing around with WinSockets
*/
#include <stdio.h>
#include <winsock.h> |
Forum: C++ Jan 3rd, 2009 |
| Replies: 5 Views: 315 First post!
Read the sticky at the top of the forum? |
Forum: C++ Aug 27th, 2008 |
| Replies: 6 Views: 712 It's called a bool in C++ ;)
You can create types with typedef.
typedef <newtype> <oldtype>
IIRC |
Forum: C++ Aug 27th, 2008 |
| Replies: 6 Views: 712 You can have a monster class with a function isHit(const unsigned int x, const unsigned int y); that returns whether the monster is hit. This makes the hit function belonging to the player really... |
Forum: C++ Aug 26th, 2008 |
| Replies: 6 Views: 712 You're coding in C++. Forget about global variables, try and make a class that has all those variables. If you can't fit it in a class or function you're quite possibly doing something wrong. ... |