0

[SOLVED] MarketingSimulator

I am making a marketing simulator for a course I am doing, they have provided a code challenge with a little example code that works well in the main.cpp, however when I add it to the implementation of the class I get errors: Severity Code Description Project File Line Suppression State Error (active) E0109 expression preceding parentheses of apparent call must have (pointer-to-) function type Merkelex C:\Users\c\source\repos\something\something\something.cpp 88 Severity Code Description Project File Line Suppression State Error C2064 term does not evaluate to a function taking 0 arguments Something C:\Users\c\source\repos\something\something\something.cpp 90 My question is why am I receiving this error and how would I solve it? https://code.sololearn.com/cYejbet2paS8/#cpp

26th Apr 2022, 7:28 PM
Charlie Crease-huggett
4 Antworten
+ 1
The problem is that you attempt to call a member function through a pointer-to-member-function without supplying the object to call the function from. The syntax for this is somewhat unique: https://stackoverflow.com/questions/14814158/c-call-pointer-to-member-function For example, if you want to use the current object (i.e. the one processOption() is currently called from), you could write: (this->*menu[userOption])();
27th Apr 2022, 10:44 AM
Shadow
Shadow - avatar
+ 1
Your code is too long for the description and therefore truncated. Please paste it into a playground project and link that here instead: https://www.sololearn.com/post/75089/?ref=app
26th Apr 2022, 11:11 PM
Shadow
Shadow - avatar
0
https://code.sololearn.com/cYejbet2paS8/#cpp
27th Apr 2022, 10:04 AM
Charlie Crease-huggett
0
Hi Shadow, Apologies for not getting back sooner, I have been traveling. Yes that works perfectly I will now marked this as solved. Thank you again for your help!!!, Charlie
28th Apr 2022, 12:19 PM
Charlie Crease-huggett