How can you invoke the constructor from the parent class? *ruby
#include <stdio.h>
// Parent class
struct Parent {
int x;
// Constructor
Parent(int val) {
x = val;
printf("Parent constructor invoked with value: %d\n", x);
}
};
// Child class inheriting from Parent
struct Child : public Parent {
// Constructor
Child(int val) : Parent(val) {
printf("Child constructor invoked with value: %d\n", x);
}
};
// Main function
int main() {
// Create an instance of Child
Child obj(42);
return 0;
}