Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7086441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:33:00+00:00 2026-05-28T07:33:00+00:00

I developed my own Matrix class. Constructor reads a matrix from file. Matrix has

  • 0

I developed my own Matrix class. Constructor reads a matrix from file. Matrix has free cells and “walls”. Also constructor reads start and finish points for Breadth first search (to find the shortest way from Start_point to Finish_Point).
Here is code of header:

//MyMatrix.h file

#ifndef __MYMATRIX_H__
#define __MYMATRIX_H__

#include <tchar.h>
#include <iostream>
#include <deque>

//using namespace std;
#define MAX_MATRIX_SIZE 1000

#define FREE_CELL_SIGNIFICATION '0'
#define BALL_SIGNIFICATION 'B'
#define UP_SIGNIFICATION 'U'
#define DOWN_SIGNIFICATION 'D'
#define LEFT_SIGNIFICATION 'L'
#define RIGHT_SIGNIFICATION 'R'
#define START_POINT_SIGNIFICATION 'S'
#define FINISH_POINT_SIGNIFICATION 'F'

typedef std::pair<int,int> Field_Point_Type;

//#define IS_RIGHT_NEIGHBOUR_REACHABLE(Current_Point) (((Current_Point.second+1) <= Column_Count)&&((Matrix_Field[Current_Point.first][Current_Point.second+1]==FREE_CELL_SIGNIFICATION)||(Matrix_Field[Current_Point.first][Current_Point.second+1]==FINISH_POINT_SIGNIFICATION))) ? true : false;



class Matrix {
    private:
        int Column_Count; //Cols
        int Row_Count;//Rows
        char** Matrix_Field;
        Field_Point_Type Start_Point;
        Field_Point_Type Finish_Point;
        bool Matrix_Is_Correct;
    public:
        Matrix(_TCHAR* Input_File_Name);
        int Breadth_first_search(unsigned int Start_X,unsigned int Start_Y,unsigned int Finish_X,unsigned int Finish_Y);
        ~Matrix();
        inline int IS_RIGHT_NEIGHBOUR_REACHABLE(Field_Point_Type Current_Point);
};

//MyMatrix.cpp file

...

inline int Matrix::IS_RIGHT_NEIGHBOUR_REACHABLE(Field_Point_Type Current_Point)
{      
    return  (((Current_Point.second+1) <= Column_Count)&&((Matrix_Field[Current_Point.first][Current_Point.second+1]==FREE_CELL_SIGNIFICATION)||(Matrix_Field[Current_Point.first][Current_Point.second+1]==FINISH_POINT_SIGNIFICATION))) ? true : false;
}

...

I’d like to define are the neighbour cells free for the next step of algorithm.
Of course I can use such code for this:

if (((Current_Point.second+1) <= Column_Count)&&((Matrix_Field[Current_Point.first][Current_Point.second+1]==FREE_CELL_SIGNIFICATION)||(Matrix_Field[Current_Point.first][Current_Point.second+1]==FINISH_POINT_SIGNIFICATION))) {
    //Adding of right cell to deque...
    ... 
}

but it looks ugly. I am going to add such checks for left, up and down cells.
I’d like to implement inline functions (like this: inline int IS_RIGHT_NEIGHBOUR_REACHABLE(Field_Point_Type Current_Point);).

if (IS_RIGHT_NEIGHBOUR_REACHABLE(Current_Point)) {
    //Adding of right cell to deque...
    ... 
}

It looks much better!
But I haven’t use such definition of inline function before and discovered it accidentally.
Is it good programming style?
Is it better to develop simple int IS_RIGHT_NEIGHBOUR_REACHABLE(Field_Point_Type Current_Point); method within my class?
Is it better to leave such check:

if (((Current_Point.second+1) <= Column_Count)&&((Matrix_Field[Current_Point.first][Current_Point.second+1]==FREE_CELL_SIGNIFICATION)||(Matrix_Field[Current_Point.first][Current_Point.second+1]==FINISH_POINT_SIGNIFICATION))) {
    //Adding of right cell to deque...
    ... 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:33:00+00:00Added an answer on May 28, 2026 at 7:33 am

    I don’t think we have an established “good style” yet. Compilers capable of inlining functions from a separately compiled .cpp file are rather recent models of the most popular compilers.

    Until a couple of years ago you had to have all inline functions in a .h file, so the compiler could see it while compiling the call. If your compiler is not the latest model, that might still be the rule.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing my own matrix class in c++ to help me develop my understanding
I've developed an own file format for configuration files (plaintext and line based ->
I've developed my own delivery extension for Reporting Services 2005, to integrate this with
If we have developed our own ORM framework and the framework is working fine
We have our own custom calendar in our portal which is developed in Java.
In our development environment each developer has their own dev server. Often times they
I've developed my own custom users and roles objects using ActiveRecord that do NOT
i had made my own .deb package for media player developed by me,but when
I developed a iPhone application for my client. I have my own developer account,
I've developed my own framework for iPhone. Among my classes, I have classes to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.