I have a class with defined functions that need to be passed as parameters.
I want to setup a new instance of this class (with parameters) as an object(?).
Getting stuck with the syntax.
class classname{
void classfunction1(int, int);
void classfunction2(int, int);
};
void classname::classfunction1 (int a, int b)
{ // function }
void classname::classfunction2 (int a, int b)
{ // function uses classfunction1 }
I want to define the params for classfunction1, which will be used in classfunction 2 and assign an object(?), of that type so that intellisense will pick it up.
Pseudo:
int main(){
classname(20, 20) object;
object.classfunction2(50, 50);
}
Thanks!
Your main is a bit wonky at the minute.
The class you have defined does not have any member variables, so it does not
storeany data. It only holds two functions. So this means that you can use the “default constructor” that the compiler defines for every class ( you can provide your own if you wish ).If you wanted to provide a constructor you should do something like:
You main would then look like:
A couple of things to note: The way you attempted to call the first constructor was wrong, you need the parameters after the variable name.
See comments below for another thing to watch out for.