Oct 23, 2008 at 10:53pm UTC
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
#include <iostream>
#include <vector>
#include "Time.h"
#include "callParticipant.h"
#include "supportPerson.h"
#include "expert.h"
#include "standardSupportPerson.h"
#include "novice.h"
#include "caller.h"
#include "EasyCaller.h"
#include "averageCaller.h"
#include "difficultCaller.h"
using namespace std;
int main()
{
int i;
vector <callParticipant *> cp(6);
cp[0] = new novice(2);
cp[1] = new standardSupportPerson(2);
cp[2] = new expert(2);
cp[3] = new EasyCaller(2);
cp[4] = new averageCaller(2);
cp[5] = new difficultCaller(2);
for ( i=0; i< 6; i++)
{
cout<< cp[i]->getMultiplier() <<endl;
}
system("pause" );
return 0;
}
I am getting error C2061: syntax error : identifier 'novice' for all of my new declarations
Last edited on Oct 23, 2008 at 10:54pm UTC
Oct 23, 2008 at 11:05pm UTC
It's not picking up your novice declaration. Have you called it Novice instead? Remember C++ is case-sensitive.
Edit: It's also better to use vector.push_back() instead of assigning it like an array as you are doing.
Last edited on Oct 23, 2008 at 11:05pm UTC
Oct 23, 2008 at 11:27pm UTC
novice.h is my header file name this is happening for all of my novice standardSupportPerson and expert headers I have checked to make sure they are all spelled and cased correctly. I am not familiar with the vector.push_back() as I have only been doing c++ for a little over 3 months now. my problem seems to be in the vector block as I have commented out the lines and my program compiles fine.
Last edited on Oct 23, 2008 at 11:28pm UTC
Oct 23, 2008 at 11:29pm UTC
Can you post the contents of novice.h please.
Oct 23, 2008 at 11:37pm UTC
And SupportPerson.h please.
Oct 23, 2008 at 11:41pm UTC
Your supportPerson needs to implement the functions getMultiplier, getType and it's constructor with 1 argument. Otherwise, make the functions pure-virtual.
Oct 23, 2008 at 11:45pm UTC
This is supposed to be an abstract class the uses the concrete classes to getmultiplier and constructor of each derived class. Atleast that is how it was explained to me by my professor
Oct 23, 2008 at 11:53pm UTC
so it should read
1 2
virtual int getMultiper();
virtual string GetType();
??
Last edited on Oct 23, 2008 at 11:53pm UTC
Oct 24, 2008 at 12:02am UTC
ok so why am I getting the problem with my concrete classes that they are not recognized identifiers?
Oct 24, 2008 at 12:07am UTC
In supportPerson.h you have #include "Caller.h"
make it callParticipant.
Last edited on Oct 24, 2008 at 12:07am UTC
Oct 24, 2008 at 12:18am UTC
Also. I don't know why this is an abstract/concrete task. I would've done it like this.
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
class callParticipant {
public :
callParticipant(int multiplier = 1) {
if (multiplier > 0)
iMultiplier = m;
else
iMultiplier = 1;
}
string getType() { return sType; }
int getMultiplier() { return iMultiplier; }
};
class Novice : public callParticipant {
Novice(int multiplier) : callParticipant(multiplier) {
sType = "Easy Call" ;
}
};
class Expert : public callParticipant {
Expert(int multiplier) : callParticpant(multiplier) {
sType = "Hard Call" ;
}
}
int main() {
vector<callParticipant*> vList;
vList.push_back(new Expert(3));
vList.push_back(new Novice(2));
return 0;
}
Last edited on Oct 24, 2008 at 12:19am UTC
Oct 24, 2008 at 12:33am UTC
what does the push_back do exactly?
Oct 24, 2008 at 12:37am UTC
adds the element to the vector.
Oct 24, 2008 at 1:01am UTC
Thank you for your help Zaita