Share your repls and programming experiences

← Back to all posts
Calculator in C++ - Now supporting temp conversions!
DavidShen2 (55)

Hi all,


I just happened to be scrolling through my repls and happened to see this repl that I worked on for a while when I was just learning C++. I cleaned it up a bit and decided it was something worthy of sharing.


  • Basic Operations
  • Log
  • Trig
  • Temp Conversion

How to use:

  • Start the repl
  • Enter the corresponding number to the desired operation
  • Enter the first number
  • Enter the second number (if appliable)
  • Enjoy the result!

Please give feedback and as always, enjoy!
Thanks in advance!

Edit: I know that the code is messy and just bad. I wrote this like 2 years ago!

EpicGamer007 (559)

You could have just used namespace std.. It would have been much easier..

DavidShen2 (55)

@EpicGamer007 I have heard stuff about how it's bad practice.

fuzzyastrocat (671)

@DavidShen2 Good, don't do it. The problems arise when there's a standard library thing, say "std::string", and then you define a type called 'string'. Since "std::string" is actually "string" now, you have a name conflict (multiple definitions of the same thing), but you wouldn't expect that since it's actually "std::string".

@EpicGamer007 1 word: reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee :D

EpicGamer007 (559)

@fuzzyastrocat , I know about that, it is just. So many std::cout's...

fuzzyastrocat (671)

@EpicGamer007 You could do auto cout = std::cout; if you really wanted to, sorta like an import cout from std

EpicGamer007 (559)

@fuzzyastrocat , wait nvm you could do

using std::cout; and using std::cin; and using std::endl;

fuzzyastrocat (671)

@EpicGamer007 Ah right, I'm not a C++ person so that makes sense. (Why do people use endl on repl? Since we know it's not Windows, and therefore it's not \r\n, just use the char literal '\n' since it's faster...)

EpicGamer007 (559)

@fuzzyastrocat . yeah i know, "\n" is wayy better.

DynamicSquid (3586)

lol what does this line do?

std::string operation;  //Copyright © 2019 David Shen

how can you copyright a variable?

Also might want to use \n instead of endl since it's faster. but cool!

DavidShen2 (55)

@DynamicSquid I wasn't trying to copyright that variable. I just put it at a random spot. :D

DynamicSquid (3586)

@DavidShen2 oh lol why don't you put it at the top?