ok so my last issue was solved, and because there's so much code posted in that topic, I figured I'd start a new one with fresh, up-to-date code for you guys so yall wouldn't get confused.
ok, so my updated code is as follows:
Bookstore.h
CODE
#ifndef BOOKSTORE_H
#define BOOKSTORE_H
#include <string>
#include <iostream>
using namespace std;
class Bookstore
{
private:
int iPrice;
int iPurchNum;
int iTotal;
public:
Bookstore( void );
~Bookstore();
void SetPurchaseNum( int & nr );
int GetPurchaseNum( );
void SetPrice( int & p );
int GetPrice( );
};
#endif;
FictionBook.h
CODE
#ifndef FICTIONBOOK_H
#define FICTIONBOOK_H
#include <string>
using namespace std;
#include "Bookstore.h"
class FictionBook:public Bookstore
{
private:
public:
void SetBookName( string & n );
string GetBookName();
};
#endif;
NonFictionBook.h
CODE
#ifndef NONFICTIONBOOK_H
#define NONFICTIONBOOK_H
#include <string>
using namespace std;
#include "Bookstore.h"
class NonFictionBook:public Bookstore
{
private:
public:
void SetBookName( string & n );
string GetBookName();
};
#endif;
Magazine.h
CODE
#ifndef MAGAZINE_H
#define MAGAZINE_H
#include <string>
using namespace std;
#include "Bookstore.h"
class Magazine:public Bookstore
{
private:
public:
void SetMagazineName( string & n );
string GetmagazineName();
};
#endif;
Includes.h
CODE
#ifndef INCLUDES_H
#define INCLUDES_H
#include <iostream>
#include <string>
using namespace std;
#include "Bookstore.h"
#include "FictionBook.h"
#include "Magazine.h"
#include "NonFictionBook.h"
#endif;
and my cpp files.
Main.cpp
CODE
#include "Includes.h"
void main ( void );
void main()
{
string sName;
string sBookName;
cout << "Please enter your name: \n";
cin >> sName;
cout << endl << "Hello, " << sName << ", and welcome to Land'o'Books!\n\n";
cout << " What would you like to purchase today?\n\n";
cout << "\t 1. Fiction Book \t 2. NonFiction Book \t 3. Magazine\n";
cin.get();
}
Bookstore.cpp
CODE
#include "Includes.h"
Bookstore::Bookstore()
{
cout << "Constructor firing off...\n";
}
ok, so what I'm thinking is I want to use a switch case. In other words, after this bit of code:
CODE
cout << " What would you like to purchase today?\n\n";
cout << "\t 1. Fiction Book\n \t 2. NonFiction Book\n \t 3. Magazine\n\n";
I want to go something like...
CODE
cout << " What would you like to purchase today?\n\n";
cout << "\t 1. Fiction Book\n \t 2. NonFiction Book\n \t 3. Magazine\n\n";
switch ( iChoice )
case 1:
FictionBook *oFictionBook = new FictionBook;
FictionBook::SetBookName( string & n );
FictionBook::GetBookName();
FictionBook::SetPurchNum( int & nr );
FictionBook::GetPurchNum();
FictionBook::SetPrice( int & p );
FictionBook::GetPrice();
break;
case 2:
//Same thing for NonFictionBook;
break;
case 3:
//Same thing for Magazine;
break;
would something like that work?
EDIT: I just noticed I double posted a new topic. I didn't mean to do that. Sorry.
EDIT EDIT: such and such variables like 'n' and whatnot are undeclared. I was unsure exactly what those variables are supposed to be?
This post has been edited by circuspeanuts: 19 Aug, 2008 - 08:51 PM