I have the following class with the 2 pointers to block
#ifndef SCORING_H
#define SCORING_H
#include "Block.h"
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
class Scoring
{
public:
Scoring(Block *, Block*, string, string, double);
virtual ~Scoring();
Scoring(const Block& b1, const Block &b2);
private:
Block * b1;
Block * b2;
string path1;
string path2;
double val;
};
#endif // SCORING_H
Class Block is the following:
class Block {
public :
///constructo
Block(double, double, double, double, int, vector<LineElement*>);
///Setter functions
void setID(int);
void setTop(double);
void setLeft(double);
void setRight(double);
void setBottom(double);
void setLine(vector<LineElement*>);
int getID();
double getTop();
double getLeft();
double getBottom();
double getRight();
vector<LineElement*> getLine();
private:
int id;
vector<LineElement*> Listline;
double top;
double left;
double bottom;
double right;
};
#endif // ELEMENT_H_INCLUDED
I want to know, Should I construct a copy constructor for "Block * b1;Block * b2" and how can I treat these 2 points in the class scoring.h?
Thank you.
Block::getLinejust returns theListLine? Remember that this will cause the whole vector top be copied which might not be what you want. You should probably return a reference instead, e.g.vector<LineElement*>& getLine();. If you don't want the callers to modify the vector then make itconst(as well as thegetLinefunction).