Class

This is a discussion on Class within the C++ Programming forums, part of the General Programming Boards category; Hi
My compilator returns an error in case of my new class, which is in future supposed to operate a ...

Also, why are all your method names prefixed with an underscore? Aside from being unnecessarily unreadable, it's also invalid: all identifiers starting with a underscore followed by another underscore or an uppercase letter are globally reserved for the implementation.

Also, why are all your method names prefixed with an underscore? Aside from being unnecessarily unreadable, it's also invalid: all identifiers starting with a underscore followed by another underscore or an uppercase letter are globally reserved for the implementation.

What CornedBee means is that because you have a constructor defined in your class:

Code:

Calculator();

you need to implement it somewhere:

Code:

Calculator::Calculator() {
/* ... */
}

And you should make sure that whatever file contains this implementation of Calculator() is included in your project and linked along with the rest of your program.

Also, why are you using floats instead of doubles? Doubles give you more precision. There's really no reason to use floats nowadays, especially if you need precision, as you probably would in a calculator.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

>> but for this example it works. Doesnt it?
Maybe, maybe not. But you should still move it. You can either put into a cpp file like calculator.cpp, or you can move it to inside the class declaration.

>> But still the same error appears:
Now its complaining about the destructor. Have you implemented any of the functions yet? If not, then you will get these same errors for any functions you use but don't actually define.

>> About the type of integers, there is no reason I do not use double ints
I think you are confused about terminology. An integer is a whole number, a floating point number is a number with a decimal or fractional part. The int type only works on integers, but you want a floating point type, so you used float. However, C++ provides a type called double which is probably better than float for you. I'm not sure what the 38 has to do with anything, where did you get that number?