In: Computer Science
using correct c++ syntax, in one part write a short header file with only one constructor and one private variable. in another part write the function definition for the same constructor of the header file you just wrote.
using a correct c++ syntax, write only the top line of a derived header file that uses a base class. write the function definitions of two constructors in this derived class
Header File with only one private variable and constuctor :
Num.h
class Num
{
//private variable
private:
int num;
//constructor
public:
Num(int num);
};
another part has constructor definition of header file.
Num.cpp
#include <iostream>
#include "Num.h"
using namespace std;
//implementation of constuctor
Num::Num(int n): num(n)
{
cout << "number : " << n << endl;
}
In another file, import a header file and call that constructors.
Main.cpp
#include "Num.h"
int main()
{
Num n1(35);
Num n2(15);
return 0;
}
OUTPUT :