Help with logic in cout
The << has the red error lines for some reason. And I don't know what's wrong b/c it looks right.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include "Enemy.h"
#include "Lion.h"
#include <conio.h>
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char* argv[]){
const int max_enemy = 20;
Enemy* enemy_ptr[max_enemy];
int num_enemy = 5;
srand(time(0));
for( int i = 0; i < 5; i++){
enemy_ptr[max_enemy] = new Lion();
}
while(true){
argc= rand()%num_enemy;
cout << enemy_ptr[argc]->fire_weapon();
}
}
|
1 2 3 4
|
void Lion::fire_weapon(){
cout << "Roar, I bit you!" << endl;
}
|
I'm just trying to test the fire_weapon() function in Lion, but the cout "<<" won't work in main.
This is probably a simple question, thanks.
1 2 3 4 5 6 7 8 9 10 11 12
|
for( int i = 0; i < 5; i++)
{
// enemy_ptr[max_enemy] = new Lion();
enemy_ptr[i] = new Lion();
}
while(true) // infinite loop
{
argc= rand()%num_enemy;
//cout << enemy_ptr[argc]->fire_weapon();
enemy_ptr[argc]->fire_weapon();
}
|
ahh.. Thanks JlBorges!
I appreciate your help.
I should have looked into it more.
Topic archived. No new replies allowed.