Ah, that's right, totally forgot about that. I'll just create a vector of pointers with all the objects on class A and then and another on class B pointing to same place. It will still do what I want...
Type: Posts; User: Litz
Ah, that's right, totally forgot about that. I'll just create a vector of pointers with all the objects on class A and then and another on class B pointing to same place. It will still do what I want...
My bad, I'll change it.
EDIT: Or I would but can't change topic name apparently? It was supposed to say vector of pointers to objects stored in a vector I guess.
The add function already does that though. It's something like this:
void B::add(object* x)
{
vec.push_back (x);
}
Oh sorry, my bad, I didn't mean to write A::classes[some index].add (&something), but A::classes[some index].add (&A::vec[A::vec.size()-1]), so I would add the copy the vector created, and not the...
So I'm working on a program, and I wanted to do something like this:
Class A has a vector<object>, where all the objects of that type are stored in. Each time a new object is created, I push it...
You just compile the program, creating an executable you can run, just like any c++ console application. Start reading a book and you'll understand it.
Pay someone to do it or do it yourself. Also, stop making stupid topics. If you need help with something you're coding, post away, but don't expect anyone to actually write you a full program. This...
You are erasing whatever the iterator "it" is pointing at, making "it" a null pointer, and then you try to use it. At least that's what it seems, but it's kinda hard to read through all that. Please...
That C part kinda draws me back.. I don't really know C (and I'm not really interested in learning it just for OpenGL). Is DirectX more C++ oriented? I could always just learn that instead of OpenGL...
See your while loop? You wrote this:
while ((playerInPet != "cat") && (playerInPet != "dog") && (playerInPet != "eagle"));
Notice how you added a ; in the end of it. Basically you're ending the...
You removed the transform statement. Basically if you enter "Dog" now, it will fail as you're not transforming the string to lower-case.
Why do you have this on your source code?
while(playerInPet != "cat" or "dog" or "eagle")
Like it was said above, replace it by this and it will work:
while( (playerInPet != "cat") &&...
So I'm really just a C++ console programmer, but recently I started wanting to learn about graphics and movement. As such, I thought it would be a good idea to do some game programming, to get a...
The cast will round it down as it basically cuts off the decimal part of the number.
The code seems fine though.
I didn't check the file or anything, but since you have the code done, all you have to do is compile it to create the executable.
I didn't read the whole program but since you said you're just having problems with the file, I assume that's the only problem. So, is the file being opened? Add a condition to check if the file is...
You need to actually open the file before reading it.
First, define fin with "ifstream fin". Then, open the file. To do that, you use "fin.open ("payroll.txt"). When you're done reading all the...
Please don't bump old topics. Last post was in 2006.
Didn't even remember when I was typing, my bad.
Basically, a class has two parts: public and private. Private members aren't meant to be accessed by anything else.
For example, if your "speed" variable was public, you could change its value...
You are making some confusions in that code, and doing things you don't really need to.
You want to display the square of all numbers in a range, and calculate their average, so you only really...
I don't really understand what you're saying. That code compiles (and works) fine...
I don't really understand your question. Mind to show us an example where it doesn't work?
while (!infile)
Isn't that just returning false right away when you have input?
Try to remove the negation and try again.
Also, I haven't really looked at the rest of the code.. If you're...
You could add a condition to check if scores[counter] is -1, after reading the first number.
There's also lots of other things you could improve. Function int main () should always return 0; your...