expected primary-expression before ‘.’ token C++

So i am trying to call my member function which is static from my main function. However, i get the error `expected primary-expression before "." token`. What does this error mean in terms of my code? and how could i fix it? it shows up both times when i call `rollTwoDie(Die d1,Die d2)` by `Die.rollTwoDie(regDieBag[i], loadedDieBag[i]);` and im not sure why im getting this error. Oh and im not sure if this helps or not, but loadedDieBag contains the derived class object LoadedDie which is derived from the base class Die below.

My part of my Die.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 #include<iostream>
    #include <cstdlib>
    using namespace std;
    
    class Die{
    	public:
    		Die();
    		Die(int numSide);
    		virtual int roll() const;
    		static int rollTwoDice(Die d1, Die d2); 
    		int side;
    };
    
    
    int Die::rollTwoDice(Die d1, Die d2){
    	return d1.roll()+d2.roll();
    }



My Tester class:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    #include "LoadedDie.cpp"
    #include<iostream>
    #include<time.h>
    #include <stdlib.h> 
    using namespace std;
    
    int main(){
    
   	Die *regDieBag[10];
    	cout << "Rolling dice from regular dice bag..."<<endl;
    	cout << "Dice[";
    	for (int i = 0; i < 10; i++){
    		regDieBag[i] = new Die(SIZE);
    		if (i == 9){
    			cout << "Die" << (i+1) << ": " << regDieBag[i]->roll() << "]" <<endl;
    		}else{
    			cout << "Die" << (i+1) << ": " << regDieBag[i]->roll() << ", ";
    		}
    	}
    	
    	LoadedDie *loadedDieBag[10];
    	cout << endl << "Rolling dice from loaded dice bag..."<<endl;
    	cout << "LoadedDice[";
    	for (int i = 0; i < 10; i++){
    		loadedDieBag[i] = new LoadedDie(SIZE);
    		if (i == 9){
    			cout << "Die" << (i+1) << ": " << loadedDieBag[i]->roll() << "]" <<endl;
    		}else{
    			cout << "Die" << (i+1) << ": " << loadedDieBag[i]->roll() << ", ";
    		}
    	}
    	
    	cout << endl << "Rolling regular and loaded dice again and finding sum of both dice..."<<endl;
    	cout << "SUM [";
    	for (int i = 0; i < 10; i++){
    		loadedDieBag[i] = new LoadedDie(SIZE);
    		if (i == 9){
    		//error occurs at the line below when i do Die.rollTwo...
	cout << "Die" << (i+1) << ": " << Die.rollTwoDie(regDieBag[i], loadedDieBag[i]) << "]" <<endl; 
    		}else{
    			cout << "Die" << (i+1) << ": " << Die.rollTwoDie(regDieBag[i], loadedDieBag[i]) << ", ";
    		}
    	}
    	
    }
`Die' is the name of a type which you're using like a name of an object.

Maybe you want to write

Die::rollTwoDie(/* etc. */)
Topic archived. No new replies allowed.