No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
14 Posted Topics
I'm setting up a finite state machine structure as a proof of concept to be used in other projects. The states have function pointers that point to actions they are allowed to perform during certain events and transitions. I'm trying to restrict these pointers to be a part of a … | |
Hi all, To begin, I'm not certain this is the proper place to start this question, but I believe this to be a linux-linker related error rather than a code based one. I've also searched far and wide for a solution online, but others have solved the problem simply include … | |
Lets say I have a class A and I also have classes B and C that inherit from class A class A { virtual void foo()=0; //stuff } class B : class A { void foo(); //more specific stuff } class C : class A { void foo(); //more specific … | |
Goal is to create a simple class that can be used for GUI buttons. My question is how can I define a function variable, and then when constructing a 'button' define which function should be called when clicked. This obviously isn't right, but just to get the idea: [CODE] class … | |
This question may be somewhat trivial, but I'm stumped none the less. The goal is to create a 'selection box' on the screen such as for selecting units in an rts game. I'll just give the pseudo-code, its the idea that's important main loop is set up as such: [CODE] … | |
here's the basic setup: [CODE] #ifndef _GLOBALS #define _GLOBALS #include <list> #include <vector> #include "unit.h" extern std::vector <unit> reserved_units; extern std::list <unit*> active; extern std::vector <unit> generics; #endif [/CODE] [CODE] //globals.cpp #include "globals.h" #include "unit.h" #include <vector> #include <list> vector <unit> generics(15); vector <unit> reserved_units(200); list <unit*> active(0); [/CODE] unit.h … | |
Re: It is probably because you don't have a operator<< function declared for your person class. Since it's a class, the compiler won't know how to 'cout' whatever data you want. I believe this should be something along the lines of what you'd need [CODE] ostream& operator<<(ostream& outs, person& x) { … | |
Re: You can use cin.fail() that is provided in <iostream> [CODE] #include <iostream> using namespace std; void main(){ int userGuess; int rightAnswer = rand()%10 + 1; while(true){ cout << "\nYour Guess: " << endl; cin >> userGuess if(cin.fail()){ cin.clear(); cin.ignore(); cout << "Invalid" << endl; } if(userGuess == rightAnswer){ cout << … | |
I'm trying to declare a vector as a global variable, and am getting a linker error. I read up on linker problems with multi-file projects, pretty sure I've included the proper headers, used extern, and #ifdef properly, but I can't get it yet. Here is what we have: [CODE] //in … | |
Re: If you want to use the Win32 API, here is a good tutorial: [url]http://winprog.org/tutorial/start.html[/url] Allegro is a good library to use with simple games, [url]http://alleg.sourceforge.net/[/url] I recommend Allegro, it's pretty easy to use on the whole and is a good starting place for 2D graphics. | |
Hi, I'm trying to create a vector array that contains pointers, and these pointers point to objects(particles) that have been created while the program is running. How do I use the appropriate de-reference operator to use functions of the class particle? ex. particle.move(); Here is what I have and my … | |
I was just wondering in general the limitations of having moving-game objects stored inside a vector. I was experimenting with general physics where each ball/particle is a class that contains directions and magnitudes of velocity and position. Increasing the number of particles means increasing the iterations of the for loop … | |
I'm trying to overload the << operator for a class (easy, right? :P) However, I get the linker error: undefined reference to `operator<<(std::ostream&, particle const&)' Which my understanding means the compiler can't find the implementation for operator<<. I'm not sure whats going on here, since I've already implemented the function. … | |
Hey everyone, Browsed through the forums and a C++ book, but can't find what I'm doing wrong. 1)Goal is to pass colors array to a function that picks a color set from 19 options and modifies red, green, and blue to be used in an allegro function. Each color set … |
The End.