Module Practice

Hi, Im doing some practice on Class. So im doing this one example but I cant get the out put I wanted.

This is my code:


The output does not print out the name even tho I have declare string.


Can someone point me in the right direction. Cheers.
Last edited on
Yeah, you must put the first argument to the constructor in quotes--making it a string literal: Person a("James", 1946, 2010)

Also, a void function cannot have a return statement
Thanks.

Btw, can remind me again why void function cannot have a return? =D
void means that the function does not return anything, so having a return statement in such a function is pointless.
Just return; in a void funtion is possible, it means that the program control goes back to the caller of the function.
@Fransje
But without it too, the function will return control, when it reaches the end?
Yeah, that's right, so a return; at the end of a void funtion is useless. But in this case:

1
2
3
4
5
6
void SomeFunction( int* a, int b ) {
    if ( a == NULL )
        return;

    ....
}


return; ís useful.
Topic archived. No new replies allowed.