trying to pass an object in pointer to a function

im new to c++ and i need to pass myboard.board (board is in the class Cboard and it is an array of int) to a function in a class called piece however this is troubling . i need to pass it as pointer os that i could change its value here under is my code. please help :)
main.cpp
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
#include<iostream>
#include"board.h"
#include "pieces.h"

void main(){
	char location[5];
	int ov1=0,ov2=0,nv1=0,nv2=0;
	int player=0;
	int repeat=0;
	int correct =0 ;
	int boards;
	int x=0;
	Cboard myboard; // creating object
	Cpiece mypiece;
	do{
	//myboard.getvalues(&new1,&new2);
	if(repeat ==0){
	myboard.printboard();
	}
	std::cout<<std::endl;
	std::cout<<"please enter location";
	std::cin>>location;
	 myboard.board;// object array which i need to pass
	repeat=myboard.setvalues(location,&nv1,&nv2,&ov1,&ov2);
	//mypiece.piecechoice(&ov1,&ov2,boards);
	std::cout<<player;
	mypiece.piecechoice(&ov1,&ov2,&myboard.board); // the function when called 

    x=x++;
	}while (x !=4);


}

piece.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "pieces.h"
#include"board.h"
#include<iostream>

Cboard myboard;
void Cpiece::piecechoice(int *ov1,int *ov2,int *boards[8][8]){
	int piece = 0;
	int a,b;
	a=*ov1;
	b=*ov2;
myboard.board;
    switch(piece){
		case 1:
			std::cout<<"ponn";
			break;
		case 2:
			std::cout<<"ponn";
			break;
			
	}
}
You didn't declare any pointers. Just pass them by reference instead.

Take out the ampersands in line 27 and add them to line 6 in piece.cpp.
Topic archived. No new replies allowed.