+ 2

Why won’t ‘a’ be used as a function in cpp

I’m writhing this code and it won’t work the main function of it is basic math but it won’t work can someone explain to me what’s wrong and tell me the steps I need to take to complete it.

22nd Jan 2018, 1:33 PM
Lord Awesome
Lord Awesome - avatar
12 odpowiedzi
+ 3
I really, really think you can't do that. First of all, your second var is an integer, so it can't be a symbol. Second, there's no such syntax (at least I think so) in c++. What you could do is, after reading input, do "if" check for possible operation symbols and then do math in them. if(b=='+'){ d = a + c; } else if(b=='-'){ d = a - c; } etc.
22nd Jan 2018, 2:11 PM
BlazingMagpie
BlazingMagpie - avatar
+ 5
Can you provide the code??
22nd Jan 2018, 1:35 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 3
When you write a comment, there should be "+Insert..." on the same panel in bottom left. Then instead of trending select your codes and pick one.
22nd Jan 2018, 1:38 PM
BlazingMagpie
BlazingMagpie - avatar
+ 2
To be fair, I have never seen anything like "(a) (b) (c) = (d);". How is it called and what is it supposed to do?
22nd Jan 2018, 1:45 PM
BlazingMagpie
BlazingMagpie - avatar
+ 1
Also how do you post a code on ios?
22nd Jan 2018, 1:35 PM
Lord Awesome
Lord Awesome - avatar
+ 1
How?
22nd Jan 2018, 1:36 PM
Lord Awesome
Lord Awesome - avatar
+ 1
I think I got it #include <iostream> using namespace std; class MyClass{ public: MyClass(int a, int b, int c, int d); private: const int shlong; const int zillow; int dankdankbaby; int comunism; }; MyClass::MyClass(int a, int b, int c, int d) : shlong(b), zillow(d), dankdankbaby(c), comunism (a) { } int main() { int a, b, c, d; cin >> a; cin >> b; cin >> c; MyClass obj(a, b, c, d); (a) (b) (c) = (d); cout << d; return 0; }
22nd Jan 2018, 1:38 PM
Lord Awesome
Lord Awesome - avatar
+ 1
Yes I know that IV done it before on my tablet I’m now useing an iPad and it won’t work :(
22nd Jan 2018, 1:41 PM
Lord Awesome
Lord Awesome - avatar
0
A is a number b is a function like division multiplication addition and subtraction and c is the other number. D is the value of the equation and input has to be vertical like this 4 / 2 Or 10 / 5 And the output would be 2
22nd Jan 2018, 2:02 PM
Lord Awesome
Lord Awesome - avatar
0
Ok thanks I was thinking I could avoid doing that because it would be time consuming for me
22nd Jan 2018, 2:16 PM
Lord Awesome
Lord Awesome - avatar
0
7779
23rd Jan 2018, 11:02 AM
Xander Keylis
0
5622
23rd Jan 2018, 12:32 PM
Lord Awesome
Lord Awesome - avatar