| | |
Variable for + - * /
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2008
Posts: 58
Reputation:
Solved Threads: 0
I wonder for something. If it is possible to replace for example * with any kind of variable that holds either: + - * /
Something like:
Something like:
Variable = *;
double Number1 = 5;
double Number2 = 10;
double NewNumber = 0;
NewNumber = Number1 Variable Number2; 0
#2 Oct 25th, 2009
Well is it that you want the value of the variable to be changed at run-time or during compilation.
•
•
Join Date: Feb 2008
Posts: 58
Reputation:
Solved Threads: 0
0
#5 Oct 25th, 2009
Ok, that is not possible ? So the only way to do this is to do any kind of check like this.
Why I wanted to find any kind of variable is that code can be so much shorter if that was possible. This is really to "hard code" everything out.
Why I wanted to find any kind of variable is that code can be so much shorter if that was possible. This is really to "hard code" everything out.
C++ Syntax (Toggle Plain Text)
String^ Operator = "Mult"; double Number1 = 5; double Number2 = 10; double NewNumber = 0; if( Operator == "Mult" ) { NewNumber = Number1 * Number2; } else { NewNumber = Number1 - Number2; }
![]() |
Similar Threads
- variable help first time using C++ (C++)
- Basic PHP - MySQL Value into Variable (PHP)
- Session variable (ASP.NET)
- Need Help with variable initialization (Java)
- variable function parameters functionname(int a, ...) (C)
- Retreiving a Variable from a URL (PHP)
- Can draw one Frame in a variable? (Java)
- Pipe inside variable isn't working in bash (Shell Scripting)
Other Threads in the C++ Forum
- Previous Thread: How to make shapes ?
- Next Thread: Selection Sort program
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete deploy desktop directshow dll download dynamic encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node number output parameter pointer problem program programming project proxy python read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





