just started off with c++, and stackoverflow for that matter. any and help infinitely appreciated, apologies in advance if i ask something super dumb
I'm making a program to solve a problem. How many 8 digit numbers are divisible by 18 and are only comprised of the digits 1, 2 and 3. I can generate numbers, but when calling a function i made to use modulus to determine whether they're divisible by 18 or not, the function gives me the error in the title. my code is as follows:
main.cpp
#include <iostream>
#include "functions.h"
using namespace std;
int main()
{
functions f();
for(int a = 1; a<4; a++){
for(int b = 1; b<4; b++){
for(int c = 1; c<4; c++){
for(int d = 1; d<4; d++){
for(int e = 1; e<4; e++){
for(int f = 1; f<4; f++){
for(int g = 1; g<4; g++){
for(int h = 1; h<4; h++){
int number = 10000000*a + 1000000*b + 100000*c + 10000*d + 1000*e + 100*f + 10*g + h; //generates 8 digit numbers, only using the digits 1 2 and 3
cout << number << endl; //prints numbers
int y = 10; //to test this bloody function
cout << f.modu18()(y); //returns 0 or 1 from func
}}}}}}}}}
functions.h
#ifndef FUNCTIONS_H
#define FUNCTIONS_H
#include <iostream>
using namespace std;
class functions
{
public:
functions();
string modu18(int x);
protected:
private:
};
#endif
functions.cpp
#include "functions.h"
#include <iostream>
using namespace std;
functions::functions(){
cout << "Functions initialised!" << endl; //to see if this thing is actually loading
}
string functions::modu18(int x){ //this is checking whether the number is divisible by 18
if(x % 18 == 0){
return 0;
}else{
return 1;
};
} //btw, using multiple files becuase i want to learn how to make this work for the future
The exact error returned when compiling is
request for member 'modu18' in 'f', which is of non-class type 'int'
I have no clue why this is saying this, all my data types are correct, for the data and the function types. send help pls Many thanks.