(Solved) : Getting Way Many Errors Member Accessible Please Solve Project 3 Files Required Maincpp Fi Q37184488 . . .
I am getting way too many errors such as member in accessible.Please solve this project. 3 files are required. here in themain.cpp file, Sample Driver Code cs101::FlashDrive drive1( 10, 0,false ); cs101::FlashDrive drive2( 20, 0, false ); drive1.plugIn(); drive1.formatDrive( ); drive1.writeData( 5 ); drive1.pullOut( );drive2.plugIn( ); drive2.formatDrive( ); drive2.writeData( 1 );drive2.pullOut( ); cs101::FlashDrive combined = drive1 + drive2;cout << “this drive’s filled to ” << combined.getUsed() << endl; cout << “this drive’s capacity is ” <<combined.getCapacity() << endl; cs101::FlashDrive other =drive1 – drive2; cout << “the other drive’s filled to “<< other.getUsed( ) << endl; cout << “the otherdrive’s capacity is ” << other.getCapacity() << endl;if (combined > other) { cout << “looks like combined isbigger…” << endl; } else { cout << “looks like otheris bigger…” << endl; } if (drive2 > other) { cout<< “looks like drive2 is bigger…” << endl; } else {cout << “looks like other is bigger…” << endl; } if(drive2 < drive1) { cout << “looks like drive2 issmaller…” << endl; } else { cout << “looks likedrive1 is smaller…” << endl; } Help please with a Projectin C++ In C++, many of the keyboard symbols that are used betweentwo variables can be given a new meaning. This feature is calledoperator overloading and it is one of the most popular C++features. Any class can choose to provide a new meaning to akeyboard symbol. Not every keyboard letter is re-definable in thisway, but many of the ones we have encountered so far are like +, -,*, /, >and ) should compare the if the left operand’s storageused is greater than the right operand’s storage used. Usingflashdrive_2_0.cpp, enhance the FlashDriveclass so that it supportsthe operators +, -, . A sample pile of driver code is shown belowto assist you in this effort. Operators+and -should create a newFlashDrivefrom the two arguments by combining their contents. Ifyou wind up with a FlashDrivewith a value stored that exceeds itscapacity, print out an error message. If you wind up with anegative capacity or storage value, print out an error message.Operators must return booland should compare the holdings of thetwo arguments to determine which one is bigger. My strong advice isto work one operator at a time, as these steps are very error-proneand lead to many, many compile errors. Finally, I would also likeyou to place FlashDrivein namespace cs52which will affect theresulting driver code as well as the class’ .hand .cppfiles. *Note:your code will not compile until you define the cs52namespaceThis is the header file: FlashDrive 2.0 FlashDrive( ); FlashDrive(int capacity, int used, bool pluggedIn ); void plugIn( ); boolisPluggedIn( ); void pullOut( ); void writeData( int amount ); voideraseData( int amount ); void formatDrive( ); void setCapacity( intamount ); void setUsed( int amount ); int getCapacity( ); intgetUsed( ); Here is the flashdrive.cpp file #include “FlashDrive.h”#include FlashDrive::FlashDrive( ) { my_StorageCapacity = 0;my_StorageUsed = 0; my_IsPluggedIn = false; }FlashDrive::FlashDrive( int capacity, int used, bool pluggedIn ) {my_StorageCapacity = capacity; my_StorageUsed = used;my_IsPluggedIn = pluggedIn; } void FlashDrive::plugIn( ) {my_IsPluggedIn = true; } void FlashDrive::pullOut( ) {my_IsPluggedIn = false; } void FlashDrive::writeData( int amount ){ my_StorageUsed += amount; } void FlashDrive::eraseData( intamount ) { //Erase amount of data my_StorageUsed -= amount; } voidFlashDrive::formatDrive( ) { //Clear data my_StorageUsed = 0; } intFlashDrive::getCapacity( ) { return( my_StorageCapacity ); } voidFlashDrive::setCapacity( int amount ) { my_StorageCapacity =amount; } int FlashDrive::getUsed( ) { return( my_StorageUsed ); }void FlashDrive::setUsed( int amount ) { my_StorageUsed = amount; }bool FlashDrive::isPluggedIn( ) { return( my_IsPluggedIn ); } /*Create new flashdrive from arguments by adding contents */FlashDrive operator+(const FlashDrive &left, const FlashDrive&right) { int new_Capacity; if (left.my_StorageCapacity >=right.my_StorageCapacity) { new_Capacity = left.my_StorageCapacity;} else { new_Capacity = right.my_StorageCapacity; } intnew_StorageUsed = left.my_StorageUsed + right.my_StorageUsed;FlashDrive temp = FlashDrive(new_Capacity, new_StorageUsed, false);temp.checkForErrors(new_Capacity, new_StorageUsed); return temp; }/* Create new flashdrive from arguments by subtracting contents */FlashDrive operator-(const FlashDrive &left, const FlashDrive&right) { int new_Capacity; if (left.my_StorageCapacity >=right.my_StorageCapacity) { new_Capacity = left.my_StorageCapacity;} else { new_Capacity = right.my_StorageCapacity; } intnew_StorageUsed = left.my_StorageUsed – right.my_StorageUsed;FlashDrive temp = FlashDrive(new_Capacity, new_StorageUsed, false);temp.checkForErrors(new_Capacity, new_StorageUsed); return temp; }/* With < operator, compare holdings of two arguments */ booloperator<(const FlashDrive &left, const FlashDrive&right) { return (left.my_StorageUsed <right.my_StorageUsed); } /* With > operator, compare holdings oftwo arguments */ bool operator>(const FlashDrive &left,const FlashDrive &right) { return (left.my_StorageUsed >right.my_StorageUsed); } /* Check for errors and print errormessages */ void FlashDrive::checkForErrors(int new_Capacity, intnew_StorageUsed) { if (new_StorageUsed > new_Capacity) { cout<< “error: capacity exceeded by ” << new_StorageUsed -new_Capacity << ” kilobytesn”; } if (new_Capacity < 0) {cout << “error: negative capacity (” << new_Capacity<< “)n”; } if (new_StorageUsed < 0) { cout <<“error: negative storage used (” << new_StorageUsed <<“)n”; } } Sample Output this drive’s filled to 6 this drive’scapacity is 20 the other drive’s filled to 4 the other drive’scapacity is 20 looks like combined is bigger… looks like other isbigger… looks like drive2 is smaller…
Expert Answer
Answer to I am getting way too many errors such as member in accessible. Please solve this project. 3 files are required. here in …
OR