#include<iostream>
#include<fstream>
using namespace std;
//File class
class File
{
fstream file;
public:
//parameter constructor
File(char filename[])
{
//opening file
file.open(filename);
}
//default constructor
File()
{
//do nothing
}
//deconstructor
~File()//to close file..
{
if (file.fail())
{
cout << "\Error!-- file not opened...\n";
file.clear( );
}
else//means file opened ...then closing it
{
file.close();
}
}
//method to open file
void openFile(char filename[])
{
//opening file
file.open(filename);
}
//method to close file
void closeFile()
{
if (file.fail())
{
cout << "\Error!-- file not opened...\n";
file.clear( );
}
else//means file opened ...then closing it
{
file.close();
}
}
//method to write a byte to a file at index
template <class T>
void write(T b,unsigned int i)
{
//setting index position in file
file.seekp(i);
file.put(b);//inserting to file..
}
//method to read a byte to a file at index
template <class T>
void write(T &b,unsigned int i)
{
//setting index position in file
file.seekp(i);
file>>b;//reading from file....
}
};
int main()
{
return 0;
}
C++ The following task is to be submitted with one Header file that contains all of...
Provide code and full projects neatly and in proper form and in the correct header and cpp files((we have to make 3 files header file , one .cpp file for function and one more main cpp file) Template Classes – Chapter 12 Write an example of a template function that can swap 2 generic elements. Create a C++ class vector using the class diagram shown in Figure 12.2. in Liangs textbook. Do not use the C++ provided header file <vector>...
Design a class that contains: we have to make 3 files header file , one .cpp file for function and one more main cpp file 9.3 (The Account class) Design a class named Account that contains: An int data field named id for the account. A double data field named balance for the account. A double data field named annualInterestRate that stores the current interest rate. A no-arg constructor that creates a default account with id 0, balance 0, and...
Provide code and full projects neatly and in proper form and in the correct header and cpp files((we have to make 3 files header file , one .cpp file for function and one more main cpp file) Operator Overloading – Chapter 14 Design a class Complex for representing complex numbers and the write overloaded operators for adding, subtracting, multiplying and dividing 2 complex numbers. Also create a function that will print a complex number on the screen. Provide appropriate constructors...
Part (A) Note: This class must be created in a separate cpp file Create a class Employee with the following attributes and operations: Attributes (Data members): i. An array to store the employee name. The length of this array is 256 bytes. ii. An array to store the company name. The length of this array is 256 bytes. iii. An array to store the department name. The length of this array is 256 bytes. iv. An unsigned integer to store...
Refer to this header file: // Fraction class // This class represents a fraction a / b class Fraction { public: // Constructors Fraction(); // sets numerator to 1 and denominator to 1 Fraction(int num, int denom); // Setters void setNumerator(int num); void setDenominator(int denom); // getters int getNumerator()const {return num;} int getDenominator()const {return denom;} double getDecimal(){return static_cast<double> num / denom;} private: int num, denom; }; 1.Write the code for the non-member overloaded << operator that will display all of...
C++ ONLY PLEASE. CAN I GET SOME HELP WRITING THIS HEADER FILE? I MAINLY WANT TO KNOW HOW I WOULD WRITE IT WITH A TEMPLATE. PLEASE AND THANKS IN ADVANCE. **************LinkedList.h requirements************************ linked list Class EXTRA CREDIT OPPORTUNITY: Create the LinkedList class as a template class for 5 extra credit points!!! private memebers Create a structure called ListNode, which should hold a Dinosaur and a pointer to the next ListNode ListNode pointer called head – will eventually point to the...
IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header and implementation file to define an apartment class. Create a driver program to test the class, and create a make file to compile the driver program. Create two files called apartment.h and appartmentImp.cpp along with creating a driver program named testApartment.cpp containing the main function. Program Requirements: • Class attributes should include integers for number of rooms, monthly rent, and square feet, as well...
I am working in c++. My program requires me to use a header file that is provided. I must use this header file and create 5 methods: 2 constructors, 2 accessors and this operation* on a 4x4 matrix. Matrix has 16 floating point values that must be entered by user. The Two operator functions: i*t; and t+i, multiply identity (i) matrix by user input value matrix and second function add identity (i) plus user input matrix transform. These two operations...
OUTCOMES After you finish this assignment, you will be able to do the following: Define an abstract class Create concrete classes from an abstract class Overload an operator Split classes into .h and .cpp files Open files for reading Write to files Use output manipulators such as setw, fixed, and setprecision DESCRIPTION A binary arithmetic operation takes two double operands (left and right) to perform addition, subtraction, multiplication, or division on. For example, 10 + 11 is an addition (+)...
Project_10_base_files.zipMakefile (2).txtProject_10_main 1.JPGProject_10_main 2.JPGProject_10_main 3.JPGProject_10 h.JPGProject_10 cpp.JPGAny C++ technique covered in Chapters 1 through 12is allowedexcept for global variablesYou are not allowed to use any global variables.If necessary, global constants may be used.Project 10DescriptionFor this project a Date class(specifiedin the file Project_10.h) will be constructed and all function definitions will be written in the file Project_10.cpp. A makefileis provided to compile this project. The file Project_10_main.cppcontainsthe main functionthat is used to run the program.On Canvas, download the files Project_10.h, Project_10_main.cpp...