I notice the former enters the constructor I made even if the constructor has no arguments while the latter only enters the constructor I made only if it requires arguments.
WIN
// ConsoleApplication11.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
class myRectangle {
int width;
public:
int getWith();
void setWidth(int newWidth) {width = newWidth;};
myRectangle (int);
~myRectangle ();
};
myRectangle::myRectangle (int w) {
width = w;
cout << "myRectangel Constructor\n";
}
myRectangle::~myRectangle() {
cout << "destructor\n";
}
void runObject();
int _tmain(int argc, _TCHAR* argv[])
{
runObject();
int exit; cout << "\n\n";
cin >> exit;
return 0;
}
void runObject()
{
myRectangle mr (5);
}
FAIL // ConsoleApplication11.cpp : Defines the entry point for the console application. //
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
class myRectangle {
int width;
public:
int getWith();
void setWidth(int newWidth) {width = newWidth;};
myRectangle ();
~myRectangle ();
};
myRectangle::myRectangle () {
cout << "myRectangel Constructor\n";
}
myRectangle::~myRectangle() {
cout << "destructor\n";
}
void runObject();
int _tmain(int argc, _TCHAR* argv[])
{
runObject();
int exit; cout << "\n\n";
cin >> exit;
return 0;
}
void runObject()
{
myRectangle mr ();
}