Conjunto is classtype that implements an array of pointers to some other class objects, i'm trying to overload the % operator so that the result is the join of both arrays into one.
eg. array1%array2 = array1 + array2

im' trying to use methods of the class Conjunto such as insert(Page * page),
as the code below any method over &right works, but if i try:

this.insert(right);
inside that cycle i obtain answer insert is not a type....

i don't know what's wrong tried everythig i culd remember....any help woul be apreciatted.

thks.

here is the problem code.

Conjunto &Conjunto::operator%(Conjunto &right){
   
    if (&right!=this){
     for (int i=0;i<right.size();i++){
        
        
         right.list();
         this.insert(right[i]);
         }
         }
         return *this;
     }

Since we don't have the complete code to that class it's not possible to answer your question.

line 9 is the wrong brace -- maybe just a posting error ?

line 8: this is a pointer and requires pointer notation this->

Correct...it misses the code, just because i have the bad habit of programming in my natural born language, so methods could not be easely indentified by non portuguese people...

this is the code.

tried that change same error returned.... :(

#ifndef CONJUNTO_
#define	CONJUNTO_

#include <string>
#include "Pagina.h"

class Conjunto:public Pagina{
	private:
		Pagina* *pag;
		int posicaoVector;            //actual position in array
		int tamanhoVector;            //present array size
	public:
		Conjunto(Pagina *pagina);        
	    ~Conjunto();
     	
		
		
		int verTam();                    //see size of array
		bool inserir(Pagina *pagina);    //insert elemnt into array, array complete doubles its size
		void remover(Pagina &pagina);    //remove element
		void esvaziar();                 // empty array
		void existe();                   // verify if element present
		Pagina elemPos(int);             // return element position
		void listar();                   // list to std
		Conjunto &Conjunto::operator%(Conjunto &junta);
	
		
		
};




Conjunto::~Conjunto(){
    delete [] pag;
    }

Conjunto::Conjunto(Pagina *pagina){
    tamanhoVector=3;
    posicaoVector=2;
	pag=new Pagina*[tamanhoVector];
	pag[1]=pagina;
	

   }

bool Conjunto::inserir(Pagina *pagina){ 

    if(posicaoVector>=tamanhoVector){ 
        tamanhoVector*=2;
        Pagina** novoTamanhoVector=new Pagina*[tamanhoVector];
        for (int j=1;j<posicaoVector;j++){
            novoTamanhoVector[j]=pag[j];
        }
        delete [] pag;
        pag=novoTamanhoVector;
        delete [] novoTamanhoVector;
        
    }
    
    pag[posicaoVector]=pagina;
    posicaoVector++;
    return true;
}

void Conjunto::remover(Pagina &pagina){
     int i=pagina.getNumPagina();
         for (int j=i;j<10;j++){
             pag[j]=pag[j+1];
             }
}

void Conjunto::esvaziar(){
     delete [] pag;
     posicaoVector=0;     
}

void Conjunto::existe(){
}

Pagina Conjunto::elemPos(int i){
     Pagina *c;
     *c=this[i];
return *c;
}

void Conjunto::listar(){
     for (int i=1;i<posicaoVector;i++){
         cout << "CAPA Final: " << pag[i]->getTexto()<< endl;

               }
}

int Conjunto::verTam(){
    return tamanhoVector;
}
  

Conjunto &Conjunto::operator%(Conjunto &junta){
   
    if (&junta !=this){
     for (int i=1;i<junta.verTam();i++){
   
        
         junta.listar();
        this->inserir(junta[i])
         }
         }
         return *this;
     }
  




#endif

I think i figured out what's wrong.... i was caling the method, passing not a pointer as it should be...but something else....

dumb me...

thank you....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.