Question
C++ header files My header file looks like this: #ifndef PPMIMAGE_H_ #define PPMIMAGE_H_ class PpmImage{ public: void readImage(char* data); void setRows(int row){ rows = row;
C++ header files
My header file looks like this:
#ifndef PPMIMAGE_H_ #define PPMIMAGE_H_ class PpmImage{ public: void readImage(char* data); void setRows(int row){ rows = row; } void setCols(int col){ cols = col; } void setDataArray(int size){ data = new char[size]; } int getRows(){ return rows; } int getCols(){ return cols; } char* getDataArray(){ return data; }
private: int rows; int cols; char* data; }; #endif
Now, I need to implement readImage() function in my .cpp file which now only contains the main method:
#include "ppmImage.h"
using namespace std;
int main(int argc, char** argv) {
PpmImage image; image.setRows(-1); image.setCols(-1); int rows = image.getRows(); int cols = image .getCols();
}
how to implement the readImage() function in my .cpp?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started