I have a data like BigArr, arr, … declared in header:
class TableView:public QWidget
{
Q_OBJECT
public:TableView (QWidget * parent = 0);
std::vector < TXdata > BigArr;
std::vector < float > arr;
std::vector < float > arr2;
std::vector < int > arrlocKtab;
std::vector < int > arrlocKrow;
In source file I have some functions I copy/pasted from somewhere else, like:
static void
multiply (float q[4], float value)
{
q[0] *= value;
q[1] *= value;
q[2] *= value;
q[3] *= value;
}
and some other functions I made, like:
void
TableView::ShowContextMenu (const QPoint & pos) // this is a slot
{
How do I get declarations from header file to work inside copy/pasted functions. Like:
static void
multiply (float q[4], float value)
{
arr[0]= something...
I got some bad results from renaming c/p functions to void TableView::function and adding them to function list in the header file. Probably something to do with the static void &static inline void… Ty
You have to define the multiply function as part of the TableView class as follows:
Then define it in the source file like this:
Or you pass an instance of TableView into multiply() if you cant/dont want to make it a member of TableView. If you decide to pass in an instance of TableView to the function, then you’ll have to consider how to access the class members, either by making a getter function or making them public. The getter acccessor function is a cleaner solution.
Either way will work, but if you decide to make everything member functions, consider the design and make sure the class doesnt become bloated, called low cohesion: en.wikipedia.org/wiki/Single_responsibility_principle