Using map function to map to user menu options to specific functions - c++

I am new to C++ and need some help with the following:
If i have no namespace this works fine as soon as i have this i get a error :
Severity Code Description Project File Line Suppression State Error (active) E0109 expression preceding parentheses of apparent call must have (pointer-to-)
I am attaching a solution where i have implemented this code to show the error.
What i am tryng to achive is to use this map to call my menu options a user can select, it has a header file as well as the cpp implemtation file in it.
I have attached the source code with the error showing when trying to compile this.
I would greatly appreciate some help - sample attached done in visual studio Sample Code

Related

In Visual Studio C++, How to quickly find necessary header files?

I know a fair amount of Java and Eclipse IDE, but am new to Visual Studio and C++. In Eclipse/Java, if you use a predefined class, Eclipse helpfully suggests the appropriate header file to include for the code to compile. Wondering if Visual Studio has similar functionality.
For example every time I use a code sample from the web, I spend a lot of time Googling which header files to include so the code will compile. My current challenge: I'm writing a small utility that reads filenames in a directory into an array for batch renaming. For this, I'm using following code fragment:
DIR* dir;
struct dirent* dirEntry;
dirEntry = readdir(dir);
Visual Studio is giving the error message: "DIR" is unidentified. "readdir" is unidentified.Is there an efficient way to locate the appropriate header files for C++ code fragments to resolve error messages like these? Thanks.
I tested this feature in vs2019 community 16.3.6 and it works. When you hover the mouse at the location of an error, you can see an error light bulb. And click the drop-down arrow next to the error bulb to add missing #include.
You can also press Alt+Enter.
As mentioned in some answers above, Visual Studio has started offering some suggestions for header files. But as of this writing, some VS suggestions lead to other error messages. E.g. I just used getline(). VS gave error message: Identifier "getline" is unidentified. It suggested I add using namespace std::basic_istream; to my code. But this was not applicable to my code and produced additional error messages.
After stumbling around, I found a very simple solution: Visit the C++ reference website. There I searched for getline and found the header information at the following link: getline(). To fix the error, I needed to #include <string>.

"Pointer to reference" error in Visual Studio is not displayed by filename where it occurs

Some errors in Visual Studio are not displayed by the filename of the source code where they are created, which makes them difficult to find and debug.
In this particular example, I have the error pointing to #include <vector> header, but I cannot trace it to the source file where the actual code error is. Error C2528 'data': pointer to reference is illegal c:\program files (x86)\microsoft visual studio 14.0\vc\include\vector 1246
If this was a runtime error, I would be able to use the Call Stack to see where in the code the runtime crash occurred.
Is there a similar way to find this error with compiler errors? Or am I stuck looking through source code to see where the error can potentially be manually?
Just for information, this is not a post asking how to fix this particular error, but a post asking how to find the source file where the errors occur quickly. Therefore I am not posting any source code, the error provided here is an example of the type of error that would cause the confusing compiler messages,
Look in the Output tab and select 'Build' from the dropdown. You should see a 'traceback' of your error(s) there. As you have observed, the Error List tab just displays the line provoking the error.

What's the cause of a D8049 error in visual studio?

I'm creating a project with openframeworks (the full source is here: https://github.com/morphogencc/ofxAsio/tree/master/example-udpreceiver), and the empty project seems to compile fine.
I added the ASIO library, and a few header classes, and now the project seems to be give me the following error:
1>------ Build started: Project: example-udpreceiver, Configuration: Debug x64 ------
1> main.cpp
1>cl : Command line error D8049: cannot execute 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\c1xx.dll': command line is too long to fit in debug record
1>cl : Command line error D8040: error creating or communicating with child process
I couldn't find any examples of error D8049 on stackoverflow or even on Microsoft's pages, and google turned up painfully few results. The only remotely useful one was this github issue:
https://github.com/deplinenoise/tundra/issues/270
But I'm still not sure what's causing the problem. Is anyone familiar with this error, and can recommend a method for troubleshooting what's causing it?
thanks in advance!
For me, working with UE4, this was an intermittent error.
I added "bLegacyPublicIncludePaths = false;" to the innermost block of project.Build.cs and recompiled without errors.
Then I removed that line and compiled again w/o errors.
The error message suggested adding "DefaultBuildSettings = BuildSettingsVersion.V2;" to project.Target.cs which worked.
This is a bit of a weird sounding error, as it is from essentially internally generated data. However, you do have control over that. Taking the error message at face value, you probably have many/lots of defined symbols passed in on the command line (or the the ones you do have have lengthy definitions), or you may have some lengthy file paths.
If you look under the project properties, one of the selections under the C++ section is "Command Line", which will show you exactly what gets passed to the compiler. When you view that you can see where you have many or lengthy parameters, and then make changes to shorten them.
Too many defines? Put them in a header (possibly stdafx.h) and include them that way.
Long file paths? Shorten the paths, put the files somewhere else, or set up file system aliases to your real directories that use shorter paths.

Internal error: [CoreUtil/General]: index too large

How to fix the above error ? I am trying to build my code on IAR embedded workbench through makefile. While building, it throws the above error.
I think more details need to be specified. If you can paste the full error you got when compiling the code, that will help. Also compiling error must be referring to some source file with a specified line number also....It will be helpful if you can paste the snippet around the line of error from the source file.

want to buiild fruit ninja type slice effect

I am trying to use a code that draws Fruit Ninja style swiping effect using the code at https://github.com/hiepnd/CCBlade
When Compiling I get error at the line #include < list >
(CCBlade.h:14:0 CCBlade.h:14:15: error: list: No such file or directory)
It works fine when integrated with a .m file, but the error is when trying to use it with .mm
Any solutions for this ?
Did you correctly adjust build setup for compiler? In order to compile c++ source code, you need to change compiler properly in build option.
Do the following if you are using Xcode 4.2:
1. Click on the CCBlade.m file.
2. Look to the right panel (first panel is all your project files, middle panel is your codes and the last panel is the properties).
3. On the Identity and Type, select "Objective C++ Type" for the File Type.
4. Vice-versa for TouchTrailLayer.m.
Hope that helps!
I was getting errors 'inline function declared but never defined' when trying to build the project. This is due to inline C functions in the CCBlade class.
The solution to fix this is simple, rename all classes that use CCBlade with .mm file extension(Objective-C++ files). This fixes the errors.