Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- class Screen{
- char **m_ppScreen;
- int m_Width;
- int m_Height;
- public:
- Screen(int inWidth, int inHeight)
- {
- m_Width = inWidth;
- m_Height = inHeight;
- char **m_ppScreen = new char *[m_Height]; // pointer-to-pointer
- for (int i = 0; i < m_Height; i++){
- m_ppScreen[i] = new char[m_Width];
- }
- };
- ~Screen(){
- for (int i = 0; i < m_Height; i++){
- delete[] m_ppScreen[i];
- }
- delete[] m_ppScreen;
- }
- void Set(int x, int y, char pixel)
- {
- /*for (int i = 0; i< m_Width; i++)
- m_ppScreen[i] = new int[m_Height];*/
- /*for (int i = 0; i< x; i++){
- for (int j = 0; j<y; j++)
- {
- pixel >> m_ppScreen[i][j];
- }
- }*/
- m_ppScreen[x][y] = pixel;
- };
- char Peek(int x, int y)
- {
- for (int i = 0; i< x; i++){
- for (int j = 0; j<y; j++)
- {
- return m_ppScreen[i][j];
- }
- }
- /*return m_ppScreen[x][y];*/
- };
- void Display()
- {
- for (int i = 0; i < m_Height; i++){
- for (int j = 0; j < m_Width; j++)
- {
- cout << m_ppScreen[i][j] << "\t";
- }
- cout << endl;
- }
- /*for (int i = 0; i< m_Width; i++)
- delete[] m_ppScreen[i];
- delete[] m_ppScreen;*/
- };
- };
- int main(){
- int row = 0;
- int col = 0;
- char v = 'v';
- fstream myFile("Data.txt", ios::in);
- myFile >> row >> col;
- cout << "ROW: " << row << ", COL: " << col << endl;
- Screen obj(row, col);
- obj.Set(4, 3, 'v');
- myFile << obj.Peek(4, 3);
- obj.Display();
- myFile.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement