.cxx/.h class - Initializer Expected
I've ironed out all of my errors but one:
1 2 3 4
|
In file included from UnsortedType.h:1,
from UnsortedType.cxx:1,
from driver.cxx:18:
ItemType.cxx:3: error: expected initializer before âItemTypeâ
|
I have another pair of .cxx/.h files in this program that are working fine, so not sure what's wrong with this one.
ItemType.cxx
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 35 36 37 38 39 40 41 42
|
#include "ItemType.h"
ItemType::ItemType()
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// PURPOSE: Initialize data by default value.
// INPUT: None.
// PRE: None.
// OUTPUT: None.
// POST: Default values are initializied.
// NOTE: None.
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
{
id = -100;
name = "zzzzzzz";
gpa = -1.00;
major = "NUL";
gender = 'x';
numOfCS = 0;
numOfCIS = 0;
numOfFemale = 0;
numOfMale = 0;
}
ItemType::ItemType(int inId, string inName, float inGpa, string inMajor, char inGender)
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// PURPOSE: To initialize data.
// INPUT: inId, name, inGpa, inGender.
// PRE: None.
// OUTPUT: None.
// POST: Class object is constructed.
// NOTE: None.
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
{
id = inId;
name = inName;
gpa = inGpa;
gender = inGender;
major = inMajor;
}
// ...
|
//ItemType.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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
const int MAX_ITEMS = 10;
const int MAX_ID = 999;
const int MIN_ID = 111;
const float MAX_GPA = 4.0;
const float MIN_GPA = 0.0;
const float TOP_GPA = 3.0;
const char MALE = 'M';
const char FEMALE = 'F';
const string CS_MAJOR = "CS";
const string CIS_MAJOR = "CIS";
enum RelationType {LESS, EQUAL, GREATER};
class ItemType
{
public :
ItemType();
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// PURPOSE: Initialize data by default value.
// INPUT: None.
// PRE: None.
// OUTPUT: None.
// POST: Default values are initializied.
// NOTE: None.
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
ItemType(int inId, string inNamee, float inGpa, string inMajor, char inGender);
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// PURPOSE: To initialize data.
// INPUT: inId, name, inGpa, inGender.
// PRE: None.
// OUTPUT: None.
// POST: Class object is constructed.
// NOTE: None.
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// ...
private :
int id;
string name;
string major;
float gpa;
char gender;
int numOfCS;
int numOfCIS;
int numOfFemale;
int numOfMale;
};
|
These are just the tips of the code since the error seems to just related to the beginning, but if more code is needed then I can bring them up too.
Last edited on
Topic archived. No new replies allowed.