Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7668901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:28:27+00:00 2026-05-31T15:28:27+00:00

My Professor gave us this class and told us that it won’t compile. He

  • 0

My Professor gave us this class and told us that it won’t compile. He says that the donors array would conflict with the constructor. So… why would that be?

I think that the name of the Donor array might do it, but it shouldn’t be the problem because the name of the member array donor is case sensitive, and is therefore different than the class name.

Here’s the code:

#ifndef DONORS_H
#define DONORS_H

#include <string>

#include "name.h"
#include "donor.h"

using namespace std;

const int 
    DONORS_LOAD_ERROR = 1,
    DONORS_UPDATE_ERROR = 2,
    DONORS_ADD_ERROR = 3;

const int MAX_DONORS = 100;

class Donors {
public:
    Donors() : size(0) {}
    void load(string filename);
    int getSize() {return size;}
    int find(Name name);
    int add(Name name);
    int add(Name name, Donation donation, int ytd);
    void processDonation(Name name, Donation donation);
    void update(string filename);
    void print();
private:
    Donor donorsList[MAX_DONORS];
    int size;
};

#endif

The professor writes:

In this version, we’ve taken version 2, added constructors, and maximized the use of objects.

HOWEVER, the introduction of constructors breaks the declaration of the array data member inside the Donors class;
therefore THIS VERSION DOES NOT COMPILE!!!!

I’ve been discussing this with a classmate and we’re both stumped. What’s up with this C++ class?

Edit:

The compiler messages are shown below:

Compiler Error

It just occurred to me that the Donor class has a constructor. Being that we haven’t touched vectors with a ten foot pole, how on earth are we supposed to compile this?

Edit2:

Here’s the donor class:

#ifndef DONOR_H
#define DONOR_H

#include "name.h"
#include "donation.h"

using namespace std;

class Donor {
public:
    Donor(Name n, Donation ld=Donation(0, 0), int y=0) : name(n), lastDonation(ld), ytd(y) {}
    Name getName() {return name;}
    Donation getLastDonation() {return lastDonation;}
    int getYtd() {return ytd;}
    void processDonation(Donation d);
private:
    Name name;  
    Donation lastDonation;
    int ytd;
};

#endif
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:28:29+00:00Added an answer on May 31, 2026 at 3:28 pm

    Difficult to say without the definition of the Donor class, but my guess is that he added a constructor with parameters to the Donor class, so it won’t have the implicit default constructor any more.

    But now, without a default constructor, that is a constructor that can be called without arguments, you cannot declare an array of such type, because there is no way to pass on the required parameters!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So to make a long story short. A professor asked this question in class
My professor gave an example located on slide 3 of this pdf : can
I am currently working on implementing the constructor function for the vector class(my professor
I was told by a professor that dividing by zero or taking a negative
Today in the class of Java the professor came up with this example but
Our professor gave us this assignment, where we have a .txt file with the
My professor cited this example in class. Its basically a version of the Unix
My professor told us that we could choose a programming language for our next
My professor gave my class an assignment today based on object oriented programming in
My professor recently gave my class an assignment and I need help finding the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.