G
GRoll35
I have 3 files here - Header/Implementation/Driver
All it has to do is send the user's input (age)..to the class and the
class will figure out the price of the ticket. I'm suppose to create
the object and then have it display the cost of the ticket. I'm new to
using classes like this so I'm a little confused. Here is the errors I
get.
If anyone could point out where to start or something that I should
keep in mind that would be very appreciated! Thanks!
Errors: (all in the Driver)
Driver.cpp(18): error C3861: 'myImp': identifier not found, even with
argument-dependent lookup
Driver.cpp(16): error C3861: 'myImp': identifier not found, even with
argument-dependent lookup
Driver.cpp(18): error C2228: left of '.getAge' must have
class/struct/union type type is ''unknown-type''
Driver.cpp(16): error C2146: syntax error : missing ';' before
identifier 'myImp'
Driver.cpp(16): error C2065: 'Imp' : undeclared identifier
Header:
#ifndef HEADER_H
#define HEADER_H
class Header
{
private:
int age;
int ticket;
public:
Header();
Header(int);
int getAge();
};
#endif
Implantation:
#include "header.h"
Header::Header(int age1)
{
int age = age1;
}
int Header::getAge()
{
if(age < 5)
{
ticket = 0;
}
else if (age < 18)
{
ticket = 5;
}
else if (age < 56)
{
ticket = 10;
}
else if (age > 55)
{
ticket = 8;
}
return ticket;
}
Driver
#include <iostream>
#include "Imp.cpp"
using namespace std;
int main()
{
int userAge = 0;
cout << "Please Enter your age: ";
cin >> userAge;
Imp myImp(userAge);
cout << "\n";
cout << "Cost of Movie Ticket: " << myImp.getAge() << endl;
cout << "\n\n";
return 0;
}:
All it has to do is send the user's input (age)..to the class and the
class will figure out the price of the ticket. I'm suppose to create
the object and then have it display the cost of the ticket. I'm new to
using classes like this so I'm a little confused. Here is the errors I
get.
If anyone could point out where to start or something that I should
keep in mind that would be very appreciated! Thanks!
Errors: (all in the Driver)
Driver.cpp(18): error C3861: 'myImp': identifier not found, even with
argument-dependent lookup
Driver.cpp(16): error C3861: 'myImp': identifier not found, even with
argument-dependent lookup
Driver.cpp(18): error C2228: left of '.getAge' must have
class/struct/union type type is ''unknown-type''
Driver.cpp(16): error C2146: syntax error : missing ';' before
identifier 'myImp'
Driver.cpp(16): error C2065: 'Imp' : undeclared identifier
Header:
#ifndef HEADER_H
#define HEADER_H
class Header
{
private:
int age;
int ticket;
public:
Header();
Header(int);
int getAge();
};
#endif
Implantation:
#include "header.h"
Header::Header(int age1)
{
int age = age1;
}
int Header::getAge()
{
if(age < 5)
{
ticket = 0;
}
else if (age < 18)
{
ticket = 5;
}
else if (age < 56)
{
ticket = 10;
}
else if (age > 55)
{
ticket = 8;
}
return ticket;
}
Driver
#include <iostream>
#include "Imp.cpp"
using namespace std;
int main()
{
int userAge = 0;
cout << "Please Enter your age: ";
cin >> userAge;
Imp myImp(userAge);
cout << "\n";
cout << "Cost of Movie Ticket: " << myImp.getAge() << endl;
cout << "\n\n";
return 0;
}: