Jump to content

  • Log In with Google      Sign In   
  • Create Account

thor6136

Member Since 19 Mar 2012
Offline Last Active Apr 06 2012 03:57 AM

Posts I've Made

In Topic: [C++] Help me with basic organism simulation

20 March 2012 - 11:05 AM

Thank you very much rip-off, this opened up a little bit different perspective :>

In Topic: [C++] Help me with basic organism simulation

20 March 2012 - 07:38 AM

I have another questions, lets say we have a code like this

#include <iostream>
#include <vector>

using namespace std;

class ClassA
{
	 public:
	 void function_a();
};


int main(void)
{
	 ClassA classAObj;
	 vector < ClassA* > myvector;
	 myvector.push_back( classAObj ); // this part doesn't work

	 myvector[ 0 ] -> function_a();

	 return 0;
}

How do you save an object into a vector and then use it through vector to call a function?

In Topic: [C++] Help me with basic organism simulation

19 March 2012 - 04:59 PM

Thank you for your answer, i have still so much to learn, i will reorganise my code tomorrow and read more tutorials on dynamic allocation, thanks again!

Oh and btw, the problem is not in not compiling, it compiles fine. I should explain it more. It's just that both child and organism can eat only the same food, if for example child is away from food and organism is in the zone where he can sense food and wants to eat it (it should go to food coordinates) but he doesn't want to, something bugs him, he starts twitching madly, but when both child and organism are in the same zone when they can sense food, than both can eat but only the same food. They can move around independently but they cannot eat independently. Maybe i should take a little bit different approach to writing this.

Edit: ok, i fixed that, thanks to you :)

PARTNERS