mardi 28 août 2018

Why does my main.cpp not print anything from my header file

I have created my header files and main.cpp.

From my understanding, you are supposed to create your class and functions in your shapeMaker.h file then put functionality in shapeMaker.cpp and lastly class the class and its object to print its value to the screen.

However, when I do this on repl.it nothing prints to the screen.

The code does not crash or scream any errors which shows everything is connected right. However, I am met with a blank screen when I press run. Even something such as cout << "hello world" won't display.

//ShapeMaker.h

#include <iostream>
#include <string>

class ShapeMaker{
  private:
  int width = 5;
  int height = 5;
  char symbol = '*';

  protected:
  int returnCanvasWidth(int);
  int returnCanvasHeight(int);
  char returnDrawSymbol(char);
  void setCanvasHeight(int);
  void setDrawingSymbol(char);

  public:

  void drawMidCanvasHorizontal();
  void drawMidCanvasVerticalLine();
  void drawCanvasWidthSizeFilledSqaure();
  void drawCanvasWidthSizedSmilingFace();

};

//ShapeMaker.cpp

#include <iostream>
#include <string>
#include "ShapeMaker.h"

using namespace std;

int ShapeMaker::returnCanvasWidth(int width){
  cout << width;
  return width;
}

int ShapeMaker::returnCanvasHeight(int height){
  cout << height;
  return height;
}

char ShapeMaker:: returnDrawSymbol(char symbol){
  cout << symbol;
  return symbol;
}

//main.cpp

#include <iostream>
#include <string>
#include "ShapeMaker.h"
using namespace std;

int main() {
  ShapeMaker s;

  return 0; 

}

Aucun commentaire:

Enregistrer un commentaire