Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming Question: I need help debugging this. The error is in BOLD ITALICS #include stdafx.h #include #include using namespace std; class Item { string

C++ Programming Question:

I need help debugging this. The error is in BOLD ITALICS

#include "stdafx.h"

#include

#include

using namespace std;

class Item {

string Title;

string Description;

double Price;

public:

Item()

{

Title = "";

Description = "";

Price = 0;

}

// Setter Functions

void setTitle(string t)

{

Title = t;

}

void setDescription(string d)

{

Description = d;

}

void setPrice(int p)

{

Price = p;

}

// Getter Functions

string getTitle()

{

return string(Title);

}

string getDescription()

{

return string(Description);

}

int getPrice()

{

return int(Price);

}

};

// Subclasses of Item to follow;

class Book : public Item

{

int pageCount;

public:

//Setter Function

void setpageCount(int pCount)

{

pageCount = pCount;

}

//Getter Function

int getpageCount()

{

return pageCount;

}

};

class Movie : public Item

{

int Length;

public:

void setLength(int len)

{

Length = len;

}

int getLength()

{

return Length;

}

};

class CD : public Item

{

private:

int trackCount;

public:

// Setter Function

void settrackCount(int tracks)

{

trackCount = tracks;

}

// Getter Function

int gettrackCount()

{

return trackCount;

}

};

class ShoppingCart

{

private:

Item ** Items;

int count;

int n;

public:

ShoppingCart()

{

Items = new Item *[n];

count = n;

}

ShoppingCart(int n)

{

for (int j = 0; j < n; j++)

{

Items[j] = new Item();

}

}

// Add Items into Cart

void add(Item sc)

{

Item(count) = sc;

ShoppingCart operator++(const ShoppingCart d);

count++; //ERROR: error C2676: binary '++': 'Item' does not define this operator or a conversion to a type acceptable to the predefined operator

}

//Listing Items

void displayCart()

{

cout << "Shopping Cart: " << endl;

for (int j = 0; j < count; j++)

cout << Items[j]->getDescription() << endl;

}

};

class Customer

{

private:

int ID;

string firstName;

string lastName;

public:

// Setter Function

void setfirstName(int First)

{

firstName = First;

}

void setlastName(int Last)

{

lastName = Last;

}

void setID(int id)

{

ID = id;

}

// Getter Function

string getfirstName()

{

return firstName;

}

string getlastName()

{

return lastName;

}

int ID()

{

return ID;

}

};

//Begin Main

int main()

{

Customer user;

ShoppingCart sc;

user.setID = 1508;

user.setfirstName = "Jon";

user.setlastName = "Smith";

Book b1;

b1.setTitle("Book 1");

b1.setDescription("Book description");

b1.setPrice(50);

b1.setpageCount(80);

sc.add(b1);

Movie m1;

m1.setTitle("Movie 1");

m1.setDescription("Movie description");

m1.setPrice(80);

m1.setLength(90);

sc.add(m1);

CD c1;

c1.setTitle("CD 1");

c1.setDescription("CD Description.");

c1.setPrice(50);

c1.settrackCount(10);

sc.add(c1);

sc.displayCart;

return 0;

}

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

8. Demonstrate aspects of assessing group performance

Answered: 1 week ago