Código:
error: pasar ‘const bit_set’ como el argumento ‘this’ de ‘block_t bit_set::get_block_t()’ descarta a los calificadores [-fpermissive]
Código:
bit_set_2.cpp: En la función miembro ‘void bit_set::set_union(const bit_set&)’:
bit_set_2.cpp:35:37: error: pasar ‘const bit_set’ como el argumento ‘this’ de ‘block_t bit_set::get_block_t()’ descarta a los calificadores [-fpermissive]
bit_set_2.cpp: En la función miembro ‘void bit_set::set_union(const bit_set&, bit_set&)’:
bit_set_2.cpp:39:45: error: pasar ‘const bit_set’ como el argumento ‘this’ de ‘block_t bit_set::get_block_t()’ descarta a los calificadores [-fpermissive]
bit_set_2.cpp: En la función miembro ‘void bit_set::set_intersection(const bit_set&)’:
bit_set_2.cpp:43:37: error: pasar ‘const bit_set’ como el argumento ‘this’ de ‘block_t bit_set::get_block_t()’ descarta a los calificadores [-fpermissive]
bit_set_2.cpp: En la función miembro ‘void bit_set::set_intersection(const bit_set&, bit_set&)’:
bit_set_2.cpp:47:45: error: pasar ‘const bit_set’ como el argumento ‘this’ de ‘block_t bit_set::get_block_t()’ descarta a los calificadores [-fpermissive]
bit_set_2.cpp: En la función miembro ‘void bit_set::set_diff(const bit_set&)’:
bit_set_2.cpp:57:39: error: pasar ‘const bit_set’ como el argumento ‘this’ de ‘block_t bit_set::get_block_t()’ descarta a los calificadores [-fpermissive]
bit_set_2.cpp: En la función miembro ‘void bit_set::set_diff(const bit_set&, bit_set&)’:
bit_set_2.cpp:61:47: error: pasar ‘const bit_set’ como el argumento ‘this’ de ‘block_t bit_set::get_block_t()’ descarta a los calificadores [-fpermissive]
bit_set_2.cpp: En la función miembro ‘bool bit_set::contains(const bit_set&)’:
bit_set_2.cpp:75:22: error: pasar ‘const bit_set’ como el argumento ‘this’ de ‘block_t bit_set::get_block_t()’ descarta a los calificadores [-fpermissive]
bit_set_2.cpp:75:51: error: pasar ‘const bit_set’ como el argumento ‘this’ de ‘block_t bit_set::get_block_t()’ descarta a los calificadores [-fpermissive]
bit_set_2.cpp:77:2: error: expected ‘}’ before ‘else’
Código:
bit_set::bit_set(void):
block_size_(32), /*int = 32 bits*/
block_(0)
{
}
bit_set:: ~bit_set(void){
}
block_t bit_set::get_block_t() {
return block_;
}
void bit_set::set_block_t(block_t b){
block_ = b;
}
void bit_set::set_union(item_t i){
block_t nuevo = ONE_MASK;
nuevo = nuevo << i;
block_ = block_ | nuevo;
}
void bit_set::set_union(const bit_set& bs){
block_ = block_ | bs.get_block_t();
}
void bit_set::set_union(const bit_set& i_bs, bit_set& o_bs){
o_bs.set_block_t(block_ | i_bs.get_block_t());
}
void bit_set::set_intersection(const bit_set& bs){
block_ = block_ & bs.get_block_t();
}
void bit_set::set_intersection(const bit_set& i_bs, bit_set& o_bs){
o_bs.set_block_t(block_ & i_bs.get_block_t());
}
void bit_set::set_diff(item_t i){
block_t nuevo = ONE_MASK;
nuevo = nuevo << i;
block_ = block_ & (~nuevo);
}
void bit_set::set_diff(const bit_set& bs){
block_ = block_ & (~bs.get_block_t());
}
void bit_set::set_diff(const bit_set& i_bs, bit_set& o_bs){
o_bs.set_block_t(block_ & (~i_bs.get_block_t()));
}
bool bit_set::belongs(item_t i){
block_t nuevo = ONE_MASK;
nuevo = nuevo << i; /*desplazamiento a la izquierda*/
if ((nuevo & block_)==EMPTY_SET_MASK){ /*comparación con el bloque creado*/
return false;
}else{
return true;
}
}
bool bit_set::contains(const bit_set& a){
if(a.get_block_t() == (block_ & a.get_block_t())){
return true;
else{
return false;
}
}
void bit_set::write(ostream& os){
char aux[80];
itoa(aux); /*Transforma el bloque en la cadena aux*/
os << aux << std::endl;
}
Código:
#include <iostream>
using namespace std;
typedef unsigned long block_t;
typedef unsigned char item_t;
typedef unsigned char block_size_t;
#define EMPTY_SET_MASK 0x00 // Máscara hexadecimal que representa el 0
#define ONE_MASK 0x01 // Máscara hexadecimal que representa el bit más significativo a 1
class bit_set {
//========================================================================================
// Atributos privados.
//========================================================================================
private:
block_t block_;
block_size_t block_size_;
Gracias por adelantado