New answers tagged

2

A very short answer with a few things I noticed. The __destruct() function in class calculator doesn't do anything useful. The methods __construct(), getNumOne(), setNumOne(), getNumTwo() and setNumTwo() are the same in all five classes. You could use inheritance here, but to be honest, these methods are not really needed. There is no separation between ...


1

The earlier replies have already pointed out that this is C code, top to bottom, and is not at all the way you would write in C++. Since there is already a std::stack in the standard library, I'll just go over the one function you actually had to write to implement your parser. int postfixEvaluation(char* exp) Your input is not modified, so use const. But ...


2

C and C++ are two different languages. Since we're using <iostream> it's clear that this is C++ (although the Stack struct is created in a very C-like fashion). #include <string.h> Since this is C++, if we want the C++ version of functions from the C standard library, we should include the <cstring> header. This header puts the contents ...


1

#include <string.h> It's better to include <cstring>, which declares all the identifiers in the std namespace. .... Unless you do this: using namespace std; which denies you all the advantages of namespaces. So don't do that. struct Stack* s = (struct Stack*) malloc(sizeof(struct Stack)); This looks like C code, assuming that std::...


Top 50 recent answers are included