This is my first assignment and I am a little confused. It is supposed to ask favorite color, integer, then float and then print the color and float (integer) amount of times. I have created a few files and I believe properly #included them and such but something is going wrong. I knew it wasnt going to work I was just trying to get it to do something when I "make"ed it but I am not sure how to move forward.
#include <iostream>
#include "image_menu.h"
#include <string>
std::string getString(std::istream& is, std::ostream& os, const std::string& prompt) {
std::string color;
os << "What's your favorite color? ";
is >> color;
return color;
}
int getInteger(std::istream& is, std::ostream& os, const std::string& prompt) {
int num;
os << "What's your favorite number? ";
is >> num;
return num;
}
double getDouble(std::istream& is, std::ostream& os, const std::string& prompt) {
double dec;
os << "What's your favorite float? ";
is >> dec;
return dec;
}
int assignment1(std::istream& is, std::ostream& os){
getString(is, os);
getInteger(is, os);
getDouble(is, os);
return num;
my main
#include "image_menu.h"
#include <iostream>
int main() {
assignment1(std::cin, std::cout);
return 0;
}
#ifndef _IMAGE_MENU_H_
#define _IMAGE_MENU_H_
#include <iostream>
std::string getString( std::istream& is, std::ostream& os, const std::string& prompt );
int getInteger( std::istream& is, std::ostream& os, const std::string& prompt );
double getDouble( std::istream& is, std::ostream& os, const std::string& prompt );
int assignment1( std::istream& is, std::ostream& os );
#endif // _IMAGE_MENU_H_
and my Makefile
all: assignment
assignment: ppm_menu.o image_menu.o
g++ -std=c++11 -o assignment ppm_menu.o image_menu.o
ppm_menu.o: ppm_menu.cpp image_menu.h
g++ -std=c++11 -c ppm_menu.cpp
image_menu.o: image_menu.cpp image_menu.h
g++ -std=c++11 -c image_menu.cpp
I know it is asking a lot to have you guys look over it. I am not asking for you to do my homework for me just to help me understand the const std::string& prompt
stuff. I have a basic enough understanding I think to complete the assignment just not sure what to do with that parameter. (We were given the function name and params by the teacher other than that we are on our own)
Thank you so so much for any help!
Aucun commentaire:
Enregistrer un commentaire