Why am I not getting an error even if I declared a function without a type?
If the return type is accepted as some types by default, is it healthy to write codes like this?
If it already works like this with a compiler feature, then why would we even need to write void for functions?
Note: I am using Code::Blocks that has a gnu compiler that follows c++11 std if it has anything to do with it.
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
ProfitDetermine (string str="")
{
int profit=0, outcome=0, income=0, sales=0;
int numberofhc=10, insur=1000000, hccost=2000000, price=3000000;
stringstream (str) >> sales;
outcome = (numberofhc * (insur + hccost));
income = (sales*price);
profit = income - outcome;
cout << "profit is " << profit <<endl;
if (profit < 0)
cout << "lost\n";
else if (profit==0)
cout << "even\n";
else
cout << "profit\n";
}
int main()
{
string sales="";
cout << "enter the number of sales\n";
getline(cin,sales);
stringstream (sales) >> sales;
while (sales!="quit") {
ProfitDetermine(sales);
cout << "\n\nEnter the number of sales\n";
cin >> sales;
}
}