I'm afraid we will need a little bit more information than what you are giving in the subject line. Please share your code and specifically tell us what you are trying to do.
I have no idea how to start.
I was tasked to set an array to a class.
The number of arrays however is user defined which means that it is not a constant and I cant use the normal method to array the class as it is not a constant.
In My Opinion ... I think the proper question is how to create an array of objects.
If you want to create an array of objects, you should do it as follows:
1 2 3 4 5 6 7 8 9
cout << "Enter number of Bids: ";
cin >> numbids;
RollBid* pointer_name = new RollBid [numbids];
/* and somewhere in your main: */
delete [] pointer_name;
note: It would be better to us if you show your class declaration and constructor definition
I have to get data from a class into another class. But I cant do it correctly.
Please see below for my code. line 33 in int main().
My operator is also not working. Please help thank you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#pragma once
#include <iostream>
usingnamespace std;
class Work
{
private:
int worknum;
double workhour;
double rate;
public:
Work();
void setWork (int, double, double);
double getbaseprice();
void display();
};
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#pragma once
#include "work.h"
class WorkBid :
public Work
{
private:
int bidnum;
Work bidwork;
double quotation;
public:
WorkBid();
void setWorkBid(int, Work, double);
void displayWorkBid();
intoperator<(WorkBid&);
};
You do not need an operator for that. Operator< should compare two different variable by specific parameter. You should make this another member function like display and setBid.