Jump to content

  • Log In with Google      Sign In   
  • Create Account


rumpfi88

Member Since 30 Nov 2009
Offline Last Active Feb 04 2013 11:16 AM
-----

Topics I've Started

I/O File new line problem

11 January 2013 - 05:02 AM

I'm working on a program to (en-)cipher files. With some experiments concerning I/O on Windows and Linux (later on Mac OS) I recognized a difference in file length. I heard that Windows uses 2 Bytes "\r\n" for new line while UNIX systems uses just 1 Byte "\n". I fear that my file (en-)ciphering program wouldn't be platform independent. Is there a way to avoid this?

 

Main problem: Person A uses Windows and cipher a file which he sends this file to Person B who uses UNIX.

 

lg


template and map::iterator dependent scope

02 May 2012 - 05:54 AM

I have a class template "Polynomial" which uses coefficients to calculate polynomial equations. With function "eval(const std::map<char,'type'>) it calculates the equation if i.e. x = 3.

First I want to figure out if 'x' is defined (using iterators), but my GNU compiler tells me that a typename is missing. Here my code:

template<class U>
U eval(const std::map<char, U>& values)
{
  bool var_match = false;
  for(std::map<char, U>::iterator it = values.begin(); it != values.end(); it++)
  {
	 if((*it).first == varname)
	 var_match = true;
  }
  if(!var_match) throw "Variable name mismatch";
/* ... */
}

Here my attributes of class Polynomial

template<class T>
class Polynomial
{
private:
   char varname;
   std::vector<T> coefficients;
/* ... */
};

Compiler-Error (at for(...;...;...) line):
error: need ‘typename’ before ‘std::map<char, U>::iterator’ because ‘std::map<char, U>’ is a dependent scope

You have any ideas how to deal with it?

lg rumpfi88

Use of Signals for card game

09 April 2012 - 11:24 AM

I'm currently working on my own Yu-Gi-Oh! Game (I know, there are a lot of people AND a big company working on it, but it's perfect practice for me) and I think of a "Send Signal"-System everytime a player summons a monster or activates a spell/trap card. Now the problem is how to generate such a signal handler:
  • Shall I use a static class (all variables and methods are static) which tells each card what has been played/activated?
  • Is <csignal> of any use for this?
  • Shall I generate an instance of signal handler and send its reference to each Card (SignalHandler& sig_handler;)?
Would be happy for any advice from you. LG rumpfi88

starting 2 extern programs at the same time

25 February 2012 - 12:53 PM

My graphic engine (by using ray tracing) is pretty slow all by itself, so I want to try to split it into other programs running at the same time (= distributed rendering). I once tried "system()" function in another program to start the engine, and it worked.

Unfortunately it only starts 1 program after another when I'm using this code (command in Windows):

#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
   string cmd = "MyGraphicEngine.exe";
   system(cmd.c_str());
   system(cmd.c_str());

return 0;
}

Is there a possibility to run "MyGraphicEngine.exe" twice at the same time?

lg rumpfi88

Include header from previous folder

02 January 2012 - 06:32 AM

I finally started my project of creating a game (for the start with console). I put the classes into folders (i.e. Characters, Spells etc.) with abstract classes and the objects into another folder (i.e. Characters/NPC and Characters/Monsters).

To stay at folder "Characters" where my abstract class is I created in "Characters/Monsters" a new class "Goblin". Now I want to derive from Characters.

#include // I don't know the path, that's the problem
class Goblin : public Characters
{
	 // variables and (virtual) methods, I needn't know the details
};

Do you have a clue how to include the abstract class's header?

PARTNERS