I am writing a program that has a class called merchant however when I try to initialize a merchant object which takes in as parameters two arrays something is going wrong as I cannot call the functions within the merchant.cpp. Not sure where the problem is?
![Merchant merch(Antique antiques[], int quantities[]); //cout << Enter in budget: $; //cin >> budget; cin >> selection; swit](http://img.homeworklib.com/questions/61e67100-cfb6-11ea-9c80-8b1996d45332.png?x-oss-process=image/resize,w_560)
![#ifndet MERCHANT H #define MERCHANT_H #include antique.h class Merchant { public: Merchant (Antique ants[], int quants[]);](http://img.homeworklib.com/questions/624ef870-cfb6-11ea-815d-f9f5b2ecac01.png?x-oss-process=image/resize,w_560)

I have created the code provided by you
In my code a have defined another class called Antique.h to make it easily understandable to you.
Also i have defined another function called display() to show you that all the values are updated.
All code in bold is additional code for better understanding.
main.cpp
#include"Merchant.cpp"
int main()
{
//I took an array of object to Antique class to pass it
to the constructor of Merchant class.
Antique ants[10];
//Initialize the value of member of class Antique
for(int i=0;i<10;i++)
{
ants[i].setA(i);
}
//An array of type int to represent the
quantities.
int quants[]={0,1,2,3,4,5,6,7,8,9};
//Pass both the array to the constructor of newly
decleared object of class Merchant.
Merchant Merch(ants,quants);
//Display and check that the values are updated or
not.
Merch.display();
}
Merchant.h
#ifndef MERCHANT_H
#define MERCHANT_H
#include "Antique.h"
class Merchant
{
public:
Merchant(Antique ants[],int
quants[]);
void
display();
private:
Antique antiques[10];
int quantities[10];
float revenue;
};
#endif
Merchant.cpp
#include"Merchant.h"
#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;
Merchant::Merchant(Antique ants[],int quants[])
{
for(int i=0;i<10;i++)
{
antiques[i]=ants[i];
quantities[i]=quants[i];
revenue=0;
}
}
void Merchant::display()
{
for(int i=0;i<10;i++)
{
cout<<"Antiques:"<<antiques[i].getA()<<" \t
Quantity:"<<quantities[i]<<"\nRevenue:"<<revenue<<endl<<endl;
}
}
Antique.h
//A dummy definition of class Antique to show that the values are stored or not.
class Antique
{
private:
int a;
public:
void setA(int a_)
{
a=a_;
}
int getA()
{
return a;
}
};

As you can see all values are replicated in the specified member variables.
Things to verify.
I am writing a program that has a class called merchant however when I try to...
IN c++ i post this question 5 times. hope this time somebody answer.. 16.5 Homework 5 OVERVIEW This homework builds on Hw4(given in bottom) We will modify the classes to do a few new things We will add copy constructors to the Antique and Merchant classes. We will overload the == operator for Antique and Merchant classes. We will overload the + operator for the antique class. We will add a new class the "MerchantGuild." Please use the provided templates...
C++ please! OVERVIEW This homework builds on HW4. We will modify the classes to do a few new things We will add copy constructors to the Antique and Merchant classes. We will overload the == operator for Antique and Merchant classes. We will overload the + operator for the antique class. We will add a new class the "MerchantGuild." Please use the provided templates for the Antique and Merchant classes, as we simplified their functionality for this homework. Also, you...
C++ Language I have a class named movie which allows a movie object to take the name, movie and rating of a movie that the user inputs. Everything works fine but when the user enters a space in the movie's name, the next function that is called loops infinetly. I can't find the source of the problem. Down below are my .cpp and .h file for the program. #include <iostream> #include "movie.h" using namespace std; movie::movie() { movieName = "Not...
C++ programming I need at least three test cases for the program and at least one test has to pass #include <iostream> #include <string> #include <cmath> #include <iomanip> using namespace std; void temperatureCoverter(float cel){ float f = ((cel*9.0)/5.0)+32; cout <<cel<<"C is equivalent to "<<round(f)<<"F"<<endl; } void distanceConverter(float km){ float miles = km * 0.6; cout<<km<<" km is equivalent to "<<fixed<<setprecision(2)<<miles<<" miles"<<endl; } void weightConverter(float kg){ float pounds=kg*2.2; cout<<kg<<" kg is equivalent to "<<fixed<<setprecision(1)<<pounds<<" pounds"<<endl; } int main() { string country;...
I'm kind of new to programming, and I am having trouble figuring out why my program isn't running. Below is the code that I wrote for practice. I will comment where it says the error is. So the error that I'm getting is "error: no match for 'operator>>' (operand types are 'std::istream {aka std::basic_istream<char>}' ". I'm not sure why I'm getting this because I added the library <iostream> at the top. Thank you. Code: #include <iostream> using namespace std; class...
When I try to run the program it gives me an erron saying Expected expresion on this line, else if(phrase.find(sub_String)!=std::string::npos). #include #include #include using namespace std; int main( ) { // Defining variables. //Initilizing variables. int magicNum; int magicNum1; int position; int phraseLenght; string vowels = "aeiou"; string phrase; string sub; // The phrase and the sub phrase cout << "Enter a phrase:" << endl; std::getline (std::cin,phrase); cout << "Enter a 3-character sub:"...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...
Hey, so i am trying to have my program read a text file using a structure but i also want to be able to modify the results(I kinda have this part but it could be better). I cant seem to get it to read the file(all the values come up as 0 and i'm not sure why because in my other program where it wrote to the txt file the values are on the txt file) i copied and pasted...
my program wont run on my computer and im not understanding why. please help. #include<iostream> #include<iomanip> #include<string> #include "bookdata.h" #include "bookinfo.h" #include "invmenu.h" #include "reports.h" #include "cashier.h" using namespace std; const int ARRAYNUM = 20; BookData bookdata[ARRAYNUM]; int main () { bool userChoice = false; while(userChoice == false) { int userInput = 0; bool trueFalse = false; cout << "\n" << setw(45) << "Serendipity Booksellers\n" << setw(39) << "Main Menu\n\n" << "1.Cashier Module\n" << "2.Inventory Database Module\n" << "3.Report Module\n"...
C++ getline errors I am getting getline is undefined error messages. I would like the variables to remain as strings. Below is my code. #include <iostream> #include<string.h> using namespace std; int index = 0; // variable to hold how many customers are entered struct Address //Structure for the address. { int street; int city; int state; int zipcode; }; // Customer structure struct Customer { string firstNm, lastNm; Address busAddr, homeAddr; }; // Functions int displayMenu(); Customer getCustomer(); void showCustomer(Customer);...