Inheritance problem

My main program security1.cpp does not recognize my "Bond" class which is inherited from the "security class". I am not sure why (i think it has do to do with the header file) as the class is recognized in my securityPrice.cpp.Any help would be very appreciated.

here is "security1.cpp":

#include <iostream>
#include <string>
#include "securityPrice.h"
using namespace std;

int main()
{double price, discount, cashflow,value,tt;
int expiry;
string type1;
cout << "\nWhat type of security is it?\n";
getline(cin,type1);
cout << "\nWhat is the "<< type1 << "'s price?\n";
cin >> price;
cout << "\nWhat is your discount rate?\n";
cin >> discount;
cout << "\nWhat are the associated cashflows?\n";
cin >> cashflow;
cout << "\nIn how many periods will the "<< type1<< " be sold?\n";
cin >> expiry;
if (type1 == "bond")
{Bond s1;}
cout << "\nThe discounted price of your " <<type1<< " is:\n";
cout << value;
cin >> tt;
return 0;
}

here is "Security price.cpp":

#include <cmath>
#include <iostream>
#include <string>
#include "securityPrice.h"
using namespace std;

Security::Security()
{p=0;c=0;d=0;e=0;t=0;
};

void Security::setPrice(int Type,
double Price,
double Discount,
double Cashflow,
int Expiry)
{ t=Type;
p=Price;
c=Cashflow;
d=Discount;
e=Expiry;
};

class Bond:public Security
{public:
double priceBond(double p)
{double prob,rate;
cout << "\nwhat is the chance of default?\n";
cin >> prob;
prob /= 100;
cout << "\nwhat is the expected recovery rate?\n";
cin >> rate;
prob /= 100;
p = p * (1-prob) + prob * rate * p;
return p;
};};

double Security::getPrice()
{double v1,n,prob,rate;
prob = 0;
rate = 0;
n = 1 + d/100;
n = pow(n,e);
v1 = e*c/n + p/n;
return v1;
};

and the header file:

#ifndef SECURITY_H
#define SECURITY_H
class Security
{private:
double p;
double c;
double d;
int e;
int t;

public:
Security();
void setPrice( int Type,
double Price,
double Discount,
double Cashflow,
int Expiry);
double getPrice();
class Bond;
};

#endif
It looks like class Bond is declared inside securityPrice.cpp. If that is the case, the
declaration of Bond has to be moved to a header file that security1.cpp can #include.
If I put the bond class wholesale in the securityprice.h and it still doesn't work. I would rather place the code in the securityprice.cpp and declare it in the header. What are the rules as far as inheritance and header files go? I dont mind making another header file for this subclass or putting it in the main but for elegance reasons would prefer not to.
Topic archived. No new replies allowed.