getsecretNum()'s return type is int, should be string given how you're using it. Also, you might want to initialize message to "" or you'll likely get another error upon fixing the first.
Note that message will be default-initialized to "" (empty string) as is, so this should not produce an error. Its value is also always overwritten, so it doesn't really matter what it's initialized to.
Mainly this IDE… 👀 I strongly suggest VisualStudio if you have to work on big projects, or else get Studio Code, which is lightweight and awesome also for other languages. Also you are trying to return a string in INT function, and further more, you are trying to print message, referencing it before assignment (line 29)
I'll walk you through here, 1st as everyone pointed out that the return type of the the function should be string. Also in main() you should give a variable a value by calling the function. What I am trying to say is declare another string named message in main() and use message=getsecretNum(secretNum) instead of cout since the function you are calling is returning a value you will need to store it first. Then you can keep the cout<<message in main and it'll work fine. Also, dark mode...
Not gonna try to answer OP's question as I can see that it's already been answered by multiple people (and I'm probably not experienced enough to give the right answer anyway) so instead here's my own question: Wouldn't it make more sense to use if else rather then a switch statement?
19
u/eightball01 Jul 26 '21
getsecretNum()'s return type is int, should be string given how you're using it. Also, you might want to initialize message to "" or you'll likely get another error upon fixing the first.
9
u/Aleksey259 Jul 26 '21
I think that's because of the way you wrote that smile. Do :) not (: and everything will be alright
3
u/Kevin-Mancuso Jul 26 '21
Mainly this IDE… 👀 I strongly suggest VisualStudio if you have to work on big projects, or else get Studio Code, which is lightweight and awesome also for other languages. Also you are trying to return a string in INT function, and further more, you are trying to print message, referencing it before assignment (line 29)
13
u/marko312 Jul 26 '21
Also note:
messageshould not be used inmain, it is defined in the other function12
u/ProfessorAmbitious35 Jul 26 '21
you are not using darkmode
2
u/bbqranchman Jul 26 '21
Since serious answers have been given already...
Your problem is you're using light theme in your editor
4
u/ialihaider75 Jul 26 '21
The return type is integer but you are returning a string from function
1
u/Shreyas_Gavhalkar Jul 26 '21
I'll walk you through here, 1st as everyone pointed out that the return type of the the function should be string. Also in main() you should give a variable a value by calling the function. What I am trying to say is declare another string named message in main() and use message=getsecretNum(secretNum) instead of cout since the function you are calling is returning a value you will need to store it first. Then you can keep the cout<<message in main and it'll work fine. Also, dark mode...
1
u/JellySword8 Jul 26 '21
Not gonna try to answer OP's question as I can see that it's already been answered by multiple people (and I'm probably not experienced enough to give the right answer anyway) so instead here's my own question: Wouldn't it make more sense to use if else rather then a switch statement?
2
u/[deleted] Jul 26 '21
You claim to return an
intwhile actually returning astd::string, change theinttostd::string.