I'm trying to create a simple Form in C++Builder, and I'm trying to create an adding()
method in a class, but if I can, I don't want to create an object just to use a method that doesn't save any values.
This is the source of the class file:
class Op{
public:
double adding(double x, double y);
};
double Op::adding(double x, double y){
return x + y;
}
And this is the action that calls the button:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
double value1 = text1->Text.ToDouble();
double value2 = text2->Text.ToDouble();
double result = Op.adding(value1, value2);
}
But I get a compile error:
improper use of typedef 'Op'
If I have to create the object like Op operations;
, please tell me how.