#include #include #include using namespace std; int main() { char str1[] = “Hello”; // fix 2 (see strcat below) : // char str1[20] = “Hello”;…
#include #include “CRectangle.h” using namespace std; int main(){ CRectangle rectA, rectB; rectA.setValues(10, 10); rectB = dupAndDouble(rectA); cout
#include using namespace std; int main(){ A a; B b; a.show(a, b); return 0; }
Use VisualStudio (2019) to compile/execute.
// from: Savitch. Absolute C++. #include #include “DayOfYear.h” using namespace std; int main() { DayOfYear canadianDay; canadianDay.set(7, 1); canadianDay.output(); DayOfYear *ptrNewYear; ptrNewYear = new DayOfYear();…
#pragma once class A; //Forward Declaration class B { private: int _b; // A::show is a friend function to class B // so A::show has…
// from: https://en.cppreference.com/w/cpp/language/default_constructor #include using namespace std; struct A{ int x; A(int x = 1) : x(x) {} // User-defined default constructor. // If no…
// inspired from: https://docs.microsoft.com/en-us/cpp/cpp/program-termination?view=vs-2019 // abort.cpp #include #include class ShowData { public: // Constructor opens a file. // This constructor is called when the sd1…
// from: Savitch. Absolute C++ #include #include “HourlyEmployee.h” using namespace std; HourlyEmployee::HourlyEmployee() : Employee(), _wageRate(0), _hours(0){ } HourlyEmployee::HourlyEmployee(string name, string ssn, double wageRate, double hours)…