Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include using namespace std; const int SIZE = 150; class color { protected: int a[SIZE][SIZE*3]; int m; int n; public: color(); color(unsigned

#include #include #include #include using namespace std; const int SIZE = 150;

class color { protected: int a[SIZE][SIZE*3]; int m; int n;

public: color(); color(unsigned char, unsigned char, unsigned char); unsigned char r; unsigned char g; unsigned char b; static const int Width = 240; static const int height = 320; int getM()const; void setM(int m); int getN()const; void setN(int n); void writeppm(string); void createpicture();

}; int color::getM()const{ return m; } void color::setM(int M){ this->m=m; } int color::getN()const{ return n; } void color::setN(int n){ this->n=n; } color::color(){ r = 0; g = 0; b = 0; } color::color(unsigned char, unsigned char, unsigned char){ r = 0; g = 0; b = 0; } void color::writeppm(string filename){ ofstream File(filename.c_str()); int amount = 255; File

} void color::createpicture(){ color grey(127,127,127);

for(int i = 0; i

int main() { color X; X.createpicture(); X.writeppm("image1.ppm"); cout

I am not gettint the image -getting the pm, width height - but no image no cout image has been created - what I'm I doing wrong? thanks C++

Expert Answer

image text in transcribedsambswas answered this

Was this answer helpful?

0

0

1,333 answers

Problem with your code:

m and n are not set. m was found to be -2144153320 and n was 1 and hence the loop didnot work. NOTE that both the values are garbage values since m and n are never set in the code you provided.

We must set m and n to their default values inside the constructor (both default and parameterized). That should make the code work as intended.

I hope this resolves your issue. If this does not resolve your issue, please let me know. Shall help you to resolve the issue.

View comments (1)

****************my code and someone's answer to why it is not working - PLEASE JUST CORRECT THAT PART OF THE CODE - I DO NOT UNDERSTAND HOW TO- THANKS c++

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

What are the components of the combined ratio? LO.1

Answered: 1 week ago