Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Problem PLEASE HELP! Objective: Create abstract classes to inherit, show polymorphic behavior and operator overloading. Complete by writing the .cpp class files. //main.cpp //User

C++ Problem PLEASE HELP!

Objective: Create abstract classes to inherit, show polymorphic behavior and operator overloading. Complete by writing the .cpp class files.

//main.cpp

//User Libraries #include #include #include #include using namespace std;

//User Libraries #include "PlusTab.h" //Global Constants

//Function Prototype void prntTab(const Table &);

//Execution Begins Here! int main(int argc, char** argv) { //Initialize the random seed srand(static_cast(time(0)));

//Declare Variables int rows = 3, cols = 4;

//Test out the Tables PlusTab tab1(rows, cols); PlusTab tab2(tab1); PlusTab tab3 = tab1 + tab2;

//Print the tables cout

//Exit Stage Right return 0; }

void prntTab(const Table &a) { cout

//AbsRow.h

#ifndef ABSROW_H #define ABSROW_H

class AbsRow { protected: int size; int *rowData; public: virtual int getSize()const = 0; virtual int getData(int)const = 0; };

#endif /* ABSROW_H */

//AbsTabl.h

#ifndef ABSTABL_H

#define ABSTABL_H

#include "RowAray.h"

class AbsTabl { protected: int szRow; int szCol; RowAray **columns; public: virtual int getSzRow()const = 0; virtual int getSzCol()const = 0; virtual int getData(int, int)const = 0; };

#endif /* ABSTABL_H */

//RowAray.h

#ifndef ROWARAY_H #define ROWARAY_H

#include "AbsRow.h"

class RowAray :public AbsRow { public: RowAray(unsigned int); virtual ~RowAray(); int getSize()const { return size; } int getData(int i)const { if (i >= 0 && i else return 0; } void setData(int, int); };

#endif /* ROWARAY_H */

//PlusTab.h

#ifndef PLUSTAB_H #define PLUSTAB_H

#include "Table.h"

class PlusTab :public Table { public: PlusTab(unsigned int r, unsigned int c) :Table(r, c) { this->szRow = r; this->szCol = c; }; PlusTab operator+(const PlusTab &); };

#endif /* PLUSTAB_H */

//Table.h

#ifndef TABLE_H #define TABLE_H

#include "AbsTabl.h"

class Table :public AbsTabl { public: Table(unsigned int, unsigned int); Table(const Table &); virtual ~Table(); int getSzRow()const { return szRow; } int getSzCol()const { return szCol; } int getData(int, int)const; void setData(int, int, int); };

#endif /* TABLE_H */

OUTPUT:

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

Solve the triangle. a 30 100

Answered: 1 week ago