Couple of things that might help steer you in the right direction.
1. There are only 24 hours in a day
2. Look up the ASCII table.
Type: Posts; User: Darkroman
Couple of things that might help steer you in the right direction.
1. There are only 24 hours in a day
2. Look up the ASCII table.
Here's what I mean
void dectobin (int * arr, unsigned char b)
{
arr[0] = (b & 128) ? 1 : 0;
if (b) dectobin (&arr[1], b << 1);
}
&arr[1] is what I'm mostly concerned about. I...
I've done it, and more. I added the option of deleting it from either the head of the list, or the tail (depending on user choice). It may be a little ugly, but suffice to say, it works. Players get...
I've figured it out through painstakingly going through how the program itself works in the memory (keeping track of it in my mind I should add...). The biggest thing I had trouble with were the...
I've not attempted, because, honestly, I don't know where to begin. FYI, it's not homework, I'm self-teaching. If I could know how to actually implement it in this specific program, it would be very...
So I've been getting back into programming, making sure I get everything covered, but there's one problem that I have NEVER been able to figure out. I've been reading 'Beginning c++ through game...
A class is like the main category of something (polygon). An instance is an object from the main category (from polygon you can make an instance of it for square, rectangle, hexagon, etc). That's the...
OK, awesome! So should I just call new instances of the class with the constructor giving different values to stats on program loading time instead?
yes, 100 enemies each with a unique value. So would it be more efficient if I made them read from a data file? And is there any other method for this?
Edit: For clarity, let's say each enemy will...
Say you have a base enemy class, but you want to have 100 different enemies... is there an efficient method to create 100 enemies (say from a base class), and provide them all with some unique value...
Not sure what any of that means. I guess I really shouldn't worry too much about it for now until I'm actually at that level of programming :) or find myself needing it.
The function prototype, and the function call within main() (or any other function) all must have the same number of arguments (the variables) and the same data types (int, string, float, bool, char...
What are the advantages and disadvantages of having your members assigned with new?
m_member = new int(10);
// or
m_member = new int(*(Foo.m_member));
I have done this before, but...
Thanks for the quick reply, guys. My next question is, do you have any references to a good tutorial on smart pointers? I've yet to learn these, and I must know the ins and outs :).
OK suppose I had a code like this
vector<base *> vec;
vec.push_back(new derived());
delete vec[0];
Code like this does compile, but I don't think I'm grasping this correctly. Basically...
Cool, good to know. I do have another question for the ReleaseCritter function. I haven't seen the use of a pointer and reference used together. I notice it compiles without & and when i run it, it...
Awesome! Thank you so much! I did notice the delete critter to case 0, that's to free the memory, and setting the pointer to 0 makes it null (I am at least familiar with that). I made an additional...
Any chance you could show me through some example code? It'd be greatly appreciated :). I'm still new with c++ and even more recently, classes. I know somewhat about using pointers and/or references...
Here's some code to give you an idea.
#include <iostream>
using namespace std;
class Critter
{
I want to know if it's possible.
Basically, I want to give the user a choice of making a new object that's part of a class. The user enters the choice and it should call a function...
Yeah, it's true I don't know much about constructors, or instances all that much yet. I just got done doing chapter 4 in accelerated c++. It introduced structures but didn't explain it all very well....
Thank you, guys! I got my program to work from following your suggestions + my own trial and error. I have one last question, and it pertains to correct use or not. So, I made an extra object for my...
OK, so I changed apple& to fruit&, and I got multiple definition errors having to do with apple, banana, or melon. After that I just got rid of the objects all together. Now it's giving me a...
Problem: I can't get this seemingly simple program to compile. I've tried searching for hours. It's a struct in a .h file along with a function prototype and its src file that uses the function to...
Thanks, I had my logic mixed up with AND and OR there with the while loops. Gotta remember AND comes to false if none or only one of the inputs are true, and OR comes to false if neither inputs are...