i want to get the number of rows from my class Matrix and rows are dynamically created.
what is the method so than i can get the number of rows.should i use dot operator?
Printable View
i want to get the number of rows from my class Matrix and rows are dynamically created.
what is the method so than i can get the number of rows.should i use dot operator?
It's better to make all data in a class private and access it with functions...
myclass c;
int data = c.getdata();
class myclass
{
public:
myclass() { data = 5; }
int getdata() { return data; }
private:
int data;
};
Have a data member in your class that gets set to the number of rows whenever the matrix gets allocated. Then simply have your method return the value of that data member. Initialize it to 0 in the constructor(s).