Can you explain why this won’t compile:
(this is the error:
../Man.cpp:33:9: error: conversion from ‘Man (*)()’ to non-scalar type ‘Man’ requested)
Code:
Man goo(){
Man m();
return m;
}
but this does:
Man goo(){
return Man();
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This means “somewhere else in the program, I will define a function named
mthat takes no arguments and returns aMan“. Yes, even when you write it inside another function.This means “
mis a variable of typeMan“. SinceManis a class type, the default constructor will be called and no parentheses are necessary.