LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-18-2003, 11:39 AM   #1
teval
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Gentoo
Posts: 720

Rep: Reputation: 30
vector<> problems


Hello,

I'm having a few problems with vector<> and was wondering if anyone can help..
I've tried to find out what's wrong (I've programmed in many langues before just not C++ that often, and I've never used vector<>)
To my understanding.. it's just a type of array created with vector<type>
Now.. I'm proting a forgotten game (Borqueror), to Linux so I can continue it's development. Fixed and rewrote the MS specific code.. but this won't complie at all.

[teval@quantum Game]$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

The problem is:

#include "stdafx.h"

#include "Planets.h"
#include "Colony.h"
#include "Technology.h"
#include "Production.h"
#include "Fleet.h"
#include "SolarSystem.h"
#include "Vessel.h"
#include "itoa.h"

const double Facility::GetEffisciency( void )
{
double ans = effisciency;

return ans;
}

void Production::UpdateAllow2Build( const int maxTechLevel )
{
availFacilities.clear();

for( vector<Technology>::iterator it = tt.begin() ; it != tt.end() ; ++it )
{
if( it->techLevel && it->techLevel <= maxTechLevel )
if( CanBuild( it ) )
availFacilities.push_back( it->name );
}
}


const bool Production::Proceed( vector<TurnEvent*> &event )
{
for( vector<Facility>::iterator it = facilities.begin() ; it != facilities.end() ; ++it )
{
vector<Technology>::iterator pos = find_if( tt.begin() , tt.end() , bind2nd( mem_fun_ref( &Technology::IsNamed ) , it->name.c_str() ) );

if( (pos->mask & 0x04) == 0x04 )
it->SetOutput( pos->prodQty * it->GetEffisciency() * it->nr );

if( (pos->mask & 0x10) == 0x10 )
{
if( pos->name == "Natural Resources" )
it->SetOutput( pos->prodQty * planet.GetOre() );
else if( pos->name == "Soil Composition" )
it->SetOutput( pos->prodQty * planet.GetSoil() );
else if( pos->name == "Planet Energy Rsc." )
it->SetOutput( pos->prodQty * planet.GetEnergy() );
else if( pos->name == "Sunrays Factor" )
it->SetOutput( pos->prodQty * planet.GetSunFactor() );
}
}

int n = 0;
bool ans = !buildStack.empty();

for( vector<BuildInProgress*>::iterator pos = buildStack.begin() ; pos != buildStack.end() ; ++pos )
{
Building( pos );
if( pos->IsBuilt() )
{
ans = true;
vector<Facility>::iterator at = find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::IsNamed ) , pos->name.c_str() ) );
if( at != facilities.end() )
at->nr += 1;
else
{
vector<Technology>::iterator ins = find_if( tt.begin() , tt.end() , bind2nd( mem_fun_ref( &Technology::IsNamed ) , pos->name.c_str() ) );
if( (ins->mask & 0x08) == 0x08 )
{
SolarSystem &ss = planet.ss;
Fleet *f = 0;
for( multimap<string,Fleet*>::iterator it = PlayGame::fleets.lower_bound( species ) ; it != PlayGame::fleets.upper_bound( species ) ; ++it )
if( it->second->GetPosition() == ss.GetPosition() )
{
f = it->second;
break;
}
if( !f )
{
bool ok = false;
int i = 0;
string fleetName;
while( !ok )
{
char tmp[10];
fleetName = species + itoa( ++i , tmp , 10 );

for( multimap<string,Fleet *>::iterator it = PlayGame::fleets.lower_bound( species ) ; it != PlayGame::fleets.upper_bound( species ) ; ++it )
if( it->second->name == fleetName )
break;
ok = (it == PlayGame::fleets.upper_bound( species ));
}
f = new Fleet( species , fleetName );
f->Setup( ss.GetPosition() , &planet );
f->Setup();
}
f->push_back( new Vessel( ins->prodName , species ) );
}
else
{
facilities.push_back( Facility( *ins , planet.GetEffisciency( species ) ) );
facilities.back().nr = 1;
}
}
event.push_back( this );
n += 1;
}
}

if( n > 0 && ans )
{
while( (pos = find_if( buildStack.begin() , buildStack.end() , mem_fun_ref( &BuildInProgress::IsBuilt ) )) != buildStack.end() )
buildStack.erase( pos );

UpdateAllow2Build();
}

return ans;
}

void Production::Building( BuildInProgress *bip )
{
for( vector<pair<string,int> >::iterator it = bip->buildRequisite.begin() ; it != bip->buildRequisite.end() ; ++it )
{
vector<Facility>::iterator pos = facilities.begin();
while( it->second )
{
if( (pos = find_if( pos , facilities.end() , bind2nd( mem_fun_ref( &Facility:oesProduce ) , it->first.c_str() ) )) != facilities.end() )
if( pos->GetOutput() >= it->second )
{
pos->AddOutput( -it->second );
it->second = 0;
}
else
{
it->second -= pos->GetOutput();
pos->SetOutput( 0 );
}
else
break;
++pos;
}
}
}

const bool Production::CanBuild( Technology *t )
{
if( !t->request.empty() )
if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::IsNamed ) , t->request.c_str() ) ) == facilities.end() )
return false;
for( vector<pair<string,int> >::iterator it = t->inputList.begin() ; it != t->inputList.end() ; ++it )
if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility:oesProduce ) , it->first.c_str() ) ) == facilities.end() )
return false;

for( it = t->buildRequisite.begin() ; it != t->buildRequisite.end() ; ++it )
if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility:oesProduce ) , it->first.c_str() ) ) == facilities.end() )
return false;

return true;
}
/*
void Production::UpdateAllow2Build( const int maxTechLevel )
{
availFacilities.clear();

for( vector<Technology>::iterator pos = tt.begin() ; it != tt.end() ; ++it )
{
if( pos->techLevel && pos->techLevel <= maxTechLevel )
if( CanBuild( pos ) )
availFacilities.push_back( it->name );
}
}
*/




The error message I get:

c++ -c -fno-for-scope -fno-const-strings -I../Source -I../Source/Game -I../Source/Distribution -I../Source/Include -I../Source/Utils -I/usr/local/include ../Source/Game/Production.cpp
../Source/Game/Production.cpp: In member function `void
Production::UpdateAllow2Build(int)':
../Source/Game/Production.cpp:26: no matching function for call to `Production
::CanBuild(__gnu_cxx::__normal_iterator<Technology*, std::vector<Technology,
std::allocator<Technology> > >&)'
../Source/Game/Production.h:112: candidates are: const bool
Production::CanBuild(Technology*)
../Source/Game/Production.cpp: In member function `const bool
Production::Proceed(std::vector<TurnEvent*, std::allocator<TurnEvent*> >&)':
../Source/Game/Production.cpp:57: conversion from `
__gnu_cxx::__normal_iterator<BuildInProgress*, std::vector<BuildInProgress,
std::allocator<BuildInProgress> > >' to non-scalar type `
__gnu_cxx::__normal_iterator<BuildInProgress**,
std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >'
requested
../Source/Game/Production.cpp:57: no match for `
__gnu_cxx::__normal_iterator<BuildInProgress**,
std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >& !=
__gnu_cxx::__normal_iterator<BuildInProgress*, std::vector<BuildInProgress,
std::allocator<BuildInProgress> > >' operator
/usr/local/include/allegro/inline/fix.inl:78: candidates are: int
operator!=(fix, fix)
/usr/local/include/allegro/inline/fix.inl:79: int
operator!=(fix, int)
/usr/local/include/allegro/inline/fix.inl:80: int
operator!=(int, fix)
/usr/local/include/allegro/inline/fix.inl:81: int
operator!=(fix, long int)
/usr/local/include/allegro/inline/fix.inl:82: int
operator!=(long int, fix)
/usr/local/include/allegro/inline/fix.inl:83: int
operator!=(fix, float)
/usr/local/include/allegro/inline/fix.inl:84: int
operator!=(float, fix)
/usr/local/include/allegro/inline/fix.inl:85: int
operator!=(fix, double)
/usr/local/include/allegro/inline/fix.inl:86: int
operator!=(double, fix)
../Source/Game/Production.cpp:59: no matching function for call to `Production
::Building(__gnu_cxx::__normal_iterator<BuildInProgress**,
std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >&)'
../Source/Game/Production.h:118: candidates are: void
Production::Building(BuildInProgress*)
../Source/Game/Production.cpp:60: request for member `IsBuilt' in `
*(&pos)->__gnu_cxx::__normal_iterator<_Iterator, _Container>:perator->()
const [with _Iterator = BuildInProgress**, _Container =
std::vector<BuildInProgress*, std::allocator<BuildInProgress*> >]()', which
is of non-aggregate type `BuildInProgress*'
../Source/Game/Production.cpp:63: request for member `name' in `
*(&pos)->__gnu_cxx::__normal_iterator<_Iterator, _Container>:perator->()
const [with _Iterator = BuildInProgress**, _Container =
std::vector<BuildInProgress*, std::allocator<BuildInProgress*> >]()', which
is of non-aggregate type `BuildInProgress*'
../Source/Game/Production.cpp:68: request for member `name' in `
*(&pos)->__gnu_cxx::__normal_iterator<_Iterator, _Container>:perator->()
const [with _Iterator = BuildInProgress**, _Container =
std::vector<BuildInProgress*, std::allocator<BuildInProgress*> >]()', which
is of non-aggregate type `BuildInProgress*'
../Source/Game/Production.cpp:113: no match for `
__gnu_cxx::__normal_iterator<BuildInProgress**,
std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >& =
__gnu_cxx::__normal_iterator<BuildInProgress*, std::vector<BuildInProgress,
std::allocator<BuildInProgress> > >' operator
/usr/include/c++/3.2.2/bits/stl_iterator.h:571: candidates are:
__gnu_cxx::__normal_iterator<BuildInProgress**,
std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >&
__gnu_cxx::__normal_iterator<BuildInProgress**,
std::vector<BuildInProgress*, std::allocator<BuildInProgress*> >
>:perator=(const __gnu_cxx::__normal_iterator<BuildInProgress**,
std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >&)
../Source/Game/Production.cpp:114: no matching function for call to `
std::vector<BuildInProgress, std::allocator<BuildInProgress> >::erase(
__gnu_cxx::__normal_iterator<BuildInProgress**,
std::vector<BuildInProgress*, std::allocator<BuildInProgress*> > >&)'
/usr/include/c++/3.2.2/bits/stl_vector.h:647: candidates are:
__gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<_Tp*,
std::vector<_Tp, _Alloc> >) [with _Tp = BuildInProgress, _Alloc =
std::allocator<BuildInProgress>]
/usr/include/c++/3.2.2/bits/stl_vector.h:670:
__gnu_cxx::__normal_iterator<_Tp*, std::vector<_Tp, _Alloc> >
std::vector<_Tp, _Alloc>::erase(__gnu_cxx::__normal_iterator<_Tp*,
std::vector<_Tp, _Alloc> >, __gnu_cxx::__normal_iterator<_Tp*,
std::vector<_Tp, _Alloc> >) [with _Tp = BuildInProgress, _Alloc =
std::allocator<BuildInProgress>]
../Source/Game/Production.cpp: In member function `void
Production::Building(BuildInProgress*)':
../Source/Game/Production.cpp:137: warning: assignment to `int' from `double'
../Source/Game/Production.cpp:137: warning: argument to `int' from `double'
make: *** [../Source/Game/Production.o] Error 1

I have no clue what to do
I know Technology as a type is defined in Technology.h, included.
And if I define any of those types without vector they work fine.. baffeled.

Thanks
 
Old 08-18-2003, 01:14 PM   #2
coolman0stress
Member
 
Registered: Jun 2003
Location: Toronto, Ontario, Canada
Posts: 288

Rep: Reputation: 30
i haven't read the whole thing, but just at a glance i can't spot the include file for vectors (#include <vectors> etc...)
 
Old 08-18-2003, 02:19 PM   #3
teval
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Gentoo
Posts: 720

Original Poster
Rep: Reputation: 30
#include <vector> is present is stdafx.h
Otherwise the error would have been something to do with the definition of vector or more likely a parse error.
It's there
Still can't figure out how to get it to work though
 
Old 08-18-2003, 04:20 PM   #4
teval
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Gentoo
Posts: 720

Original Poster
Rep: Reputation: 30
Allrighty, fixed some things
Now.. all that's left:

../Source/Game/Production.cpp: In member function `const bool
Production::Proceed(std::vector<TurnEvent*, std::allocator<TurnEvent*> >&)':
../Source/Game/Production.cpp:47: no matching function for call to `Production
::Building(__gnu_cxx::__normal_iterator<BuildInProgress*,
std::vector<BuildInProgress, std::allocator<BuildInProgress> > >&)'
../Source/Game/Production.h:118: candidates are: void
Production::Building(BuildInProgress*)
../Source/Game/Production.cpp: In member function `void
Production::Building(BuildInProgress*)':
../Source/Game/Production.cpp:125: warning: assignment to `int' from `double'
../Source/Game/Production.cpp:125: warning: argument to `int' from `double'
../Source/Game/Production.cpp: In member function `void
Production::UpdateAllow2Build(int)':
../Source/Game/Production.cpp:158: no matching function for call to `Production
::CanBuild(__gnu_cxx::__normal_iterator<Technology*, std::vector<Technology,
std::allocator<Technology> > >&)'
../Source/Game/Production.cpp:136: candidates are: const bool
Production::CanBuild(Technology*)

Code:
#include "stdafx.h"

#include "Planets.h"
#include "Colony.h"
#include "Technology.h"
#include "PlayGame.h"
#include "Production.h"
#include "Fleet.h"
#include "SolarSystem.h"
#include "Vessel.h"
#include "itoa.h"

const double Facility::GetEffisciency( void )
{
        double ans = effisciency;

        return ans;
}

const bool Production::Proceed( vector<TurnEvent*> &event )
{
        for( vector<Facility>::iterator it = facilities.begin() ; it != facilities.end() ; ++it )
        {
                vector<Technology>::iterator pos = find_if( tt.begin() , tt.end() , bind2nd( mem_fun_ref( &Technology::IsNamed ) , it->name.c_str() ) );

                if( (pos->mask & 0x04) == 0x04 )
                        it->SetOutput( pos->prodQty * it->GetEffisciency() * it->nr );

                if( (pos->mask & 0x10) == 0x10 )
                {
                        if( pos->name == "Natural Resources" )
                                it->SetOutput( pos->prodQty * planet.GetOre() );
                        else if( pos->name == "Soil Composition" )
                                it->SetOutput( pos->prodQty * planet.GetSoil() );
                        else if( pos->name == "Planet Energy Rsc." )
                                it->SetOutput( pos->prodQty * planet.GetEnergy() );
                        else if( pos->name == "Sunrays Factor" )
                                it->SetOutput( pos->prodQty * planet.GetSunFactor() );
                }
        }

        int     n = 0;
        bool    ans = !buildStack.empty();

        for( vector<BuildInProgress>::iterator pos =  buildStack.begin() ; pos != buildStack.end() ; ++pos )
        {
                Building( pos );
                if( pos->IsBuilt() )
                {
                        ans = true;
                        vector<Facility>::iterator at = find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::IsNamed ) , pos->name.c_str() ) );
                        if( at != facilities.end() )
                                at->nr += 1;
                        else
                        {
                                vector<Technology>::iterator ins = find_if( tt.begin() , tt.end() , bind2nd( mem_fun_ref( &Technology::IsNamed ) , pos->name.c_str() ) );
                                if( (ins->mask & 0x08) == 0x08 )
                                {
                                        SolarSystem     &ss = planet.ss;
                                        Fleet   *f = 0;
                                        for( multimap<string,Fleet*>::iterator it = PlayGame::fleets.lower_bound( species ) ; it != PlayGame::fleets.upper_bound( species ) ; ++it )
                                                if( it->second->GetPosition() == ss.GetPosition() )
                                                {
                                                        f = it->second;
                                                        break;
                                                }
                                        if( !f )
                                        {
                                                bool    ok = false;
                                                int     i = 0;
                                                string  fleetName;
                                                while( !ok )
                                                {
                                                        char    tmp[10];
                                                        fleetName = species + itoa( ++i , tmp , 10 );

                                                        for( multimap<string,Fleet *>::iterator it = PlayGame::fleets.lower_bound( species ) ; it != PlayGame::fleets.upper_bound( species ) ; ++it )
                                                                if( it->second->name == fleetName )
                                                                        break;
                                                        ok = (it == PlayGame::fleets.upper_bound( species ));
                                                }
                                                f = new Fleet( species , fleetName );
                                                f->Setup( ss.GetPosition() , &planet );
                                                f->Setup();
                                        }
                                        f->push_back( new Vessel( ins->prodName , species ) );
                                }
                                else
                                {
                                        facilities.push_back( Facility( *ins , planet.GetEffisciency( species ) ) );
                                        facilities.back().nr = 1;
                                }
                        }
                        event.push_back( this );
                        n += 1;
                }
        }

        if( n > 0 && ans )
        {
                while( (pos = find_if( buildStack.begin() , buildStack.end() , mem_fun_ref( &BuildInProgress::IsBuilt ) )) != buildStack.end() )
                        buildStack.erase( pos );

                UpdateAllow2Build();
        }

        return ans;
}

void Production::Building( BuildInProgress *bip )
{
        for( vector<pair<string,int> >::iterator it = bip->buildRequisite.begin() ; it != bip->buildRequisite.end() ; ++it )
        {
                vector<Facility>::iterator      pos = facilities.begin();
                while( it->second )
                {
                        if( (pos = find_if( pos , facilities.end() , bind2nd( mem_fun_ref( &Facility::DoesProduce ) , it->first.c_str() ) )) != facilities.end() )
                                if( pos->GetOutput() >= it->second )
                                {
                                        pos->AddOutput( -it->second );
                                        it->second = 0;
                                }
                                else
                                {
                                        it->second -= pos->GetOutput();
                                        pos->SetOutput( 0 );
                                }
                        else
                                break;
                        ++pos;
                }
        }
}

const bool Production::CanBuild( Technology *t )
{
        if( !t->request.empty() )
                if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::IsNamed ) , t->request.c_str() ) ) == facilities.end() )
                        return false;
        for( vector<pair<string,int> >::iterator it = t->inputList.begin() ; it != t->inputList.end() ; ++it )
                if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::DoesProduce ) , it->first.c_str() ) ) == facilities.end() )
                        return false;

        for( it = t->buildRequisite.begin() ; it != t->buildRequisite.end() ; ++it )
                if( find_if( facilities.begin() , facilities.end() , bind2nd( mem_fun_ref( &Facility::DoesProduce ) , it->first.c_str() ) ) == facilities.end() )
                        return false;

        return true;
}

void Production::UpdateAllow2Build( const int maxTechLevel )
{
        availFacilities.clear();

        for( vector<Technology>::iterator pos = tt.begin() ; pos != tt.end() ; ++pos )
        {
                if( pos->techLevel && pos->techLevel <= maxTechLevel )
                        if( CanBuild( pos ) )
                                availFacilities.push_back( pos->name );
        }
}
Also the header file for it:



Code:
#if !defined( __PRODUCTION_H__ )
#define __PRODUCTION_H__

class Planets;
#include "Technology.h"
#include "PlayGame.h"

class Facility  {
private:

        int     outputQty;

public:

        string  name , prodName;
        vector<pair<string , int> >     inputList;
        int     nr;
        double effisciency;

        Facility( Technology &tech , const double aEff = 0.0 )
        : name( tech.name ) , effisciency( aEff ) , inputList( tech.inputList )
        , outputQty( tech.prodQty ) , nr( tech.nr )
        , prodName( tech.prodName )
        {}

        ~Facility( void )       {}

        inline Facility &operator=( const Facility &f )
        {
                name = f.name;
                inputList = f.inputList;
                effisciency = f.effisciency;
                prodName = f.prodName;
                outputQty = f.outputQty;
                nr = f.nr;
                return *this;
        }
        const bool IsNamed( const char *aName ) const   {       return name == aName; }
        const bool DoesProduce( const char *aName ) const       {       return prodName == aName;       }
        const double GetOutput( void ) const    {       return outputQty * nr * effisciency;    }
        void    SetOutput( const double aQty )  {       outputQty = (int)aQty;  }
        void    AddOutput( const double aQty )  {       outputQty += (int)aQty; }
        const double GetEffisciency( void );
};

class BuildInProgress   {
public:
        string  name;
        double progress;
        vector<pair<string,int> >       buildRequisite;

        BuildInProgress( Technology &tech )
        : name( tech.name ) , progress( 0.0 ) , buildRequisite( tech.buildRequisite )
        {}

        ~BuildInProgress( void )        {}

        const bool IsNamed( const char *aName ) const   {       return name == aName; }
        inline BuildInProgress &operator=( const BuildInProgress &f )
        {
                name = f.name;
                buildRequisite = f.buildRequisite;
                progress = f.progress;
                return *this;
        }

        const bool IsBuilt( void )
        {
                int     ans = 0;
                for( vector<pair<string,int> >::iterator it = buildRequisite.begin() ; it != buildRequisite.end() ; ++it )
                        ans += it->second;
                return ans == 0;
        }
};

class Production :  public TurnEvent    {
protected:

        vector<Facility>        facilities;
        vector<string>  availFacilities;
        vector<BuildInProgress> buildStack;
        TechnologyTree  &tt;
        Planets &planet;

public:

        const string species;

        Production( Planets &aPlanet , const string aSpecies )
        : species( aSpecies ) , tt( PlayGame::Get( aSpecies ) ) , planet( aPlanet )
        {
        }

        ~Production( void )
        {
                facilities.clear();
                availFacilities.clear();
        }

        const bool CanBuild( Technology *t );

        void UpdateAllow2Build( const int maxTechLevel = 1 );

        const bool Proceed( vector<TurnEvent*> &event );

        void Building( BuildInProgress *bip );
};

#endif
Any clue how to fix the remaining errors.. i figured out what was happening but.. still haven't figured out all the errors.
 
Old 08-18-2003, 04:26 PM   #5
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
Re: vector<> problems

I'll take a run at the first error.

Quote:
Originally posted by teval

Code:
void Production::UpdateAllow2Build( const int maxTechLevel )
{
        availFacilities.clear();

        for( vector<Technology>::iterator it = tt.begin() ; it != tt.end() ; ++it )
        {
                if( it->techLevel && it->techLevel <= maxTechLevel )
                        if( CanBuild( it ) )
                                availFacilities.push_back( it->name );
        }
}

const bool Production::CanBuild( Technology *t )
{
        // ...
}
The error message I get:

c++ -c -fno-for-scope -fno-const-strings -I../Source -I../Source/Game -I../Source/Distribution -I../Source/Include -I../Source/Utils -I/usr/local/include ../Source/Game/Production.cpp
../Source/Game/Production.cpp: In member function `void
Production::UpdateAllow2Build(int)':
../Source/Game/Production.cpp:26: no matching function for call to `Production
::CanBuild(__gnu_cxx::__normal_iterator<Technology*, std::vector<Technology,
std::allocator<Technology> > >&)'
You're calling
Code:
const bool Production::CanBuild( Technology *t )
with a vector<Technology>::iterator.

Maybe you want your const bool Production::CanBuild( Technology *t ) to take a constant reference (I didn't see you write through *t in CanBuild; if you did, make it a non-const reference) to Technology and call it with the iterator dereferenced like so:

Code:
void Production::UpdateAllow2Build( const int maxTechLevel )
{
        availFacilities.clear();

        for( vector<Technology>::iterator it = tt.begin() ; it != tt.end() ; ++it )
        {
                if( it->techLevel && it->techLevel <= maxTechLevel )
                        if( CanBuild( *it ) ) // Only line changed.
                                availFacilities.push_back( it->name );
        }
}

const bool Production::CanBuild(const Technology& t)
{
        // ...
}
Maybe that helps,
Lyle
 
Old 08-18-2003, 04:28 PM   #6
teval
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Gentoo
Posts: 720

Original Poster
Rep: Reputation: 30
Thanks

I fixed the errors.. I used &(* instead of *
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vector installed slight problems ksl VectorLinux 1 07-07-2005 10:31 AM
can i modify int 80 vector to a user-defined vector qqrilxk Linux - Security 1 03-03-2005 08:46 PM
Anyone having problems with Vector Live CD 4.0? masinick VectorLinux 5 03-25-2004 12:43 PM
vector problems (possibly a broken install) laydros VectorLinux 1 11-28-2003 09:57 PM
Vector Linux Problems. rvijay Linux - General 1 09-12-2003 12:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration