C++ Define a constructor as indicated. Sample output for below program:
Year: 0, VIN: -1
Year: 2009, VIN: 444555666
#include <iostream>
using namespace std;
class CarRecord {
public:
void SetYearMade(int originalYear);
void SetVehicleIdNum(int vehIdNum);
void Print() const;
CarRecord();
private:
int yearMade;
int vehicleIdNum;
};
// FIXME: Write constructor, initialize
//year to 0, vehicle ID num to -1.
/* Your solution goes here */
void CarRecord::SetYearMade(int originalYear) {
yearMade = originalYear;
}
void CarRecord::SetVehicleIdNum(int vehIdNum) {
vehicleIdNum = vehIdNum;
}
void CarRecord::Print() const {
cout << "Year: " << yearMade << ", VIN: "
<< vehicleIdNum << endl;
}
int main() {
CarRecord familyCar;
familyCar.Print();
familyCar.SetYearMade(2009);
familyCar.SetVehicleIdNum(444555666);
familyCar.Print();
return 0;
}
#include <iostream> using namespace std; class CarRecord { public: void SetYearMade(int originalYear); void SetVehicleIdNum(int vehIdNum); void Print() const; CarRecord(); private: int yearMade; int vehicleIdNum; }; CarRecord::CarRecord() { yearMade = 0; vehicleIdNum = -1; } void CarRecord::SetYearMade(int originalYear) { yearMade = originalYear; } void CarRecord::SetVehicleIdNum(int vehIdNum) { vehicleIdNum = vehIdNum; } void CarRecord::Print() const { cout << "Year: " << yearMade << ", VIN: " << vehicleIdNum << endl; } int main() { CarRecord familyCar; familyCar.Print(); familyCar.SetYearMade(2009); familyCar.SetVehicleIdNum(444555666); familyCar.Print(); return 0; }
C++ Define a constructor as indicated. Sample output for below program: Year: 0, VIN: -1 Year:...
IN JAVA. Please reply with the solution without changing aspects of the pre-determined code. The example is for your reference and is NOT supposed to be included in the pre-determined code. Comments are helpful, too. Thank you SO much! :) -- Basic constructor definition. Define a constructor as indicated. Sample output for below program: Year: 0, VIN: -1 Year: 2009, VIN: 444555666 -- // ===== Code from file CarRecord.java ===== public class CarRecord { private int yearMade; private int vehicleIdNum;...
Overload the + operator as indicated. Sample output for the given program: First vacation: Days: 7, People: 3 Second vacation: Days: 12, People: 3 #include <iostream> using namespace std; class FamilyVacation{ public: void SetNumDays(int dayCount); void SetNumPeople(int peopleCount); void Print() const; FamilyVacation operator+(int moreDays); private: int numDays; int numPeople; }; void FamilyVacation::SetNumDays(int dayCount) { numDays = dayCount; return; } void FamilyVacation::SetNumPeople(int peopleCount) { numPeople = peopleCount; return; } // FIXME: Overload + operator so can write newVacation = oldVacation +...
Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public: static string weekDays[7]; void print() const; string nextDay() const; string prevDay() const; void addDay(int nDays); void setDay(string d); string getDay() const; dayType(); dayType(string d); private: string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...
C++ 1. The copy constructor is used for one the following scenarios: I. Initialize one object from another of the same type. II. Copy an object to pass it as argument to a function. III. Copy an object to return it from a function. Read the following program and answer questions (20 points) #include <iostream> using namespace std; class Line public: int getLength( void); Line( int len // simple constructor Line( const Line &obj) 1/ copy constructor Line (); //...
Find Output. Just output. No explanation needed.. #include <iostream> #include <string> using namespace std; class baseClass { public: void print() const; baseClass(string s = " ", int a = 0); //Postcondition: str = s; x = a; protected: int x; private: string str; }; class derivedClass: public baseClass { public: void print() const; derivedClass(string s = "", int a = 0, int b = 0); //Postcondition: str = s; x = a; y = b; private: int y; }; int...
Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string; class Account { public: Account(); Account(string, double); void deposit(double); bool withdraw(double); string getName() const; double getBalance() const; private: string name; double balance; }; #endif ////////////////////////////////////////////// //AccountManager.hpp #ifndef _ACCOUNT_MANAGER_HPP_ #define _ACCOUNT_MANAGER_HPP_ #include "Account.hpp" #include <string> using std::string; class AccountManager { public: AccountManager(); AccountManager(const AccountManager&); //copy constructor void open(string); void close(string); void depositByName(string,double); bool withdrawByName(string,double); double getBalanceByName(string); Account getAccountByName(string); void openSuperVipAccount(Account&); void closeSuperVipAccount(); bool getBalanceOfSuperVipAccount(double&) const;...
Greetings, everybody I already started working in this program. I just need someone to help me complete this part of the assignment (my program has 4 parts of code: main.cpp; Student.cpp; Student.h; StudentGrades.cpp; StudentGrades.h) Just Modify only the StudentGrades.h and StudentGrades.cpp files to correct all defect you will need to provide implementation for the copy constructor, assignment operator, and destructor for the StudentGrades class. Here are my files: (1) Main.cpp #include <iostream> #include <string> #include "StudentGrades.h" using namespace std; int...
Finish the class Matrix.h: class Matrix { public: Matrix(); //default constructor ~Matrix(); //destructor Matrix(const Matrix &); //copy constror Matrix(int row, int col); Matrix operator+(const Matrix &)const; //overload operator“+” Matrix& operator=(const Matrix &); //overload operator“=” Matrix transpose()const; //matrix transposition void display()const; //display the data private: int row; //row int col; //column int** mat; //to save the matrix }; //main.cpp #include <iostream> #include"Matrix.h" using namespace std; int main() { int row, col; cout << "input the row and the col for Matrix...
Finish the class Matrix.h: class Matrix { public: Matrix(); //default constructor ~Matrix(); //destructor Matrix(const Matrix &); //copy constror Matrix(int row, int col); Matrix operator+(const Matrix &)const; //overload operator“+” Matrix& operator=(const Matrix &); //overload operator“=” Matrix transpose()const; //matrix transposition void display()const; //display the data private: int row; //row int col; //column int** mat; //to save the matrix }; //main.cpp #include <iostream> #include"Matrix.h" using namespace std; int main() { int row, col; cout << "input the row and the col for Matrix...