37 An abstract can also have constructor | C++ Programming Tutorial for beginners | cpp | C plus p

Published: 12 March 2021
on channel: tech fort
19
1

A abstract class can also have constructors:

#include iostream
using namespace std;   
class BaseClass { // abstract class
public:
int x;
  virtual void function() = 0; //pure virtual function
BaseClass(int i) {
x = i;
}
};
class DerivedClass: public BaseClass{     
public:
int y;
    DerivedClass(int i, int j):BaseClass(i) {
y = j;
}
    void function() {
cout "\ncalling the function ";
cout "x is : " x ", y is : " y;
}
};   
int main(void) {
    DerivedClass dc=DerivedClass(14, 15);
    dc.function();
getchar();
    return 0;
}


On this page of the site you can watch the video online 37 An abstract can also have constructor | C++ Programming Tutorial for beginners | cpp | C plus p with a duration of hours minute second in good quality, which was uploaded by the user tech fort 12 March 2021, share the link with friends and acquaintances, this video has already been watched 19 times on youtube and it was liked by 1 viewers. Enjoy your viewing!