Need a little help

Posts 1–3 of 3 · Page 1 of 1
Need a little help
Been watching thenewboston's youtube tutorials, and memorising all of the tutorials.. etc

I got up to the "Dating young girls" episode in which he creates a function that calculates the minimum age of a girl that a person of your age can date...
the rule is half your age and add seven.

anyway, heres what I have done:
Code:
#include <iostream>
#include <cmath>
#include <cstdlib>

void myfun(int);

int main(){
    using namespace std;
    int age;
    cout << "Enter your age: \n";
    cin >> age;
    cout << myfun(age);
    cin.get();
    return 0;
}

void myfun(int myage){
     using namespace std;
     int girlsage = myage/2+7;
     cout << "You can date girls that are " << girlsage << " and above.\n"; 
     }
When I try to compile+run this, it gives me an error for the "cout << myfun(age)" statement in the main function. the error is "no match for operator<< in std::cout << myfun(age)". As far as I can see, I have done everything correctly, but I must be missing something. Can anyone help me out?
Youre trying to print out a void function(function with no return).

I'll let you figure out how to fix it on your own, if you need help feel free to ask ;P
*cough* make it an int function >.>
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Need help?