identifier not found errors

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
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
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
Can you post the contents of novice.h please.
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
34
#define NOVICE_H
#ifndef NOVICE_H
#include "supportPerson.h"
#include <string>

using namespace std;

class novice : public supportPerson
{
public:
novice(int m = 1) 
	{
		if(m>0)
			 multiplier = m;
		 else
			 multiplier = 1;
	}
		
	int getMultiplier()
	{
		multiplier = multiplier * 3;
		return multiplier;
	}

	string GetType() 
	{
		return "Novice";
	}
private:
		int multiplier;

};

#endif 

however I am not getting the identifier error with this EasyCaller.h
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
#ifndef EASYCALLER_H
#define EASYCALLER_H

#include "Caller.h"
#include <string>

class EasyCaller : public Caller
{
public:
	EasyCaller(int m = 1) 
	{
		if(m>0)
			 multiplier = m;
		 else
			 multiplier = 1;
	}
		
	int getMultiplier()
	{
		return multiplier;
	}

	string GetType() 
	{
		return "Easy to deal with";
	}
private:
		int multiplier;

};
#endif 

And SupportPerson.h please.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef SUPPORTPERSON_H
#define SUPPORTPERSON_H
#include "Caller.h"
#include <string>

using namespace std;

class supportPerson : public callParticipant
{
public:
virtual int getMultiplier();
virtual string GetType();
}; 

#endif 


This is supposed to be a call center simulator that is divided into parts this part is using abstract and concrete classes
Your supportPerson needs to implement the functions getMultiplier, getType and it's constructor with 1 argument. Otherwise, make the functions pure-virtual.
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
If it's abstract then it cannot be instantiated.

1
2
virtual int getMultiplier() = 0;
virtual string GetType() = 0;
so it should read
1
2
virtual int getMultiper();
virtual string GetType();

??
Last edited on
1
2
3
4
5
6
class supportPerson : public callParticipant
{
public:
virtual int getMultiplier() = 0;
virtual string GetType() = 0;
}; 
ok so why am I getting the problem with my concrete classes that they are not recognized identifiers?
In supportPerson.h you have #include "Caller.h"
make it callParticipant.
Last edited on
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
what does the push_back do exactly?
adds the element to the vector.
Thank you for your help Zaita
Topic archived. No new replies allowed.