I have searched various websites and saw many programs but could not found a single program doing it.Here are is an example from tutorials point
#include <iostream>
using namespace std;
class Line {
public:
void setLength( double len );
~setLength(); <----- An error
double getLength( void );
Line(); // This is the constructor declaration
~Line(); // This is the destructor: declaration
private:
double length;
};
// Member functions definitions including constructor
Line::Line(void) {
cout << "Object is being created" << endl;
}
Line::~Line(void) {
cout << "Object is being deleted" << endl;
}
void Line::setLength( double len ) {
length = len;
}
Line::~setLenght() //I tried void Line::~setLength too
{
cout<<"The function is deleted:"
}
double Line::getLength( void ) {
return length;
}
// Main function for the program
int main() {
Line line;
// set line length
line.setLength(6.0);
cout << "Length of line : " << line.getLength() <<endl;
return 0;
}
I have tried it myself but i did not work it may be that the code that I write was not that good but I wanted to know whether if there is an option to deconstruct a parameterized constructors and is declaring void as a parameter (Eg: line::line(void)
) making it a parameterized constructor.