| | |
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 beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





