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 9223643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:07:17+00:00 2026-06-18T04:07:17+00:00

Im trying to write a program that when the user enters a keyword for

  • 0

Im trying to write a program that when the user enters a keyword for a movie the program search it in the title and comes back with the result. I am stuck on how to try to do that . i keep getting a error about not having a default constructor in the header class. i am not sure how to fix this.

this is the header class

// Movies.h
#ifndef MOVIES_H
#define MOVIES_H
#include "Movie.h" // include Movie class definition
#include <string>
using namespace std;

class Movies {
// data is private by default
static const int MAX_MOVIES = 1000;
Movie movies[MAX_MOVIES];
int movieCnt;

public:
Movies(string);
void Test(string);
const Movie getMovie(int);


private:

void loadMovies(string);
string myToLower(string);
};
#endif

This is the cpp file for the header

// Movies.cpp
#include "Movie.h" // include Movie class definition
#include "Movies.h" // include Movies class definition
#include <fstream>
using namespace std;

 Movies::Movies(string fn){loadMovies(fn);}


 const Movie Movies::getMovie(int mc) {
return movies[mc-1];
}

void Movies::loadMovies(string fn) {
ifstream iS(fn);
string s;
getline(iS, s); // skip heading
getline(iS, s);
movieCnt=0;
while(!iS.eof()) {
    movies[movieCnt++] = Movie(s);
    getline(iS, s);
}
iS.close();
}

 void Movies::Test(string key)
{
Movies[1];
}

string Movies::myToLower(string s) {
int n = s.length();
string t(s);
for(int i=0;i<n;i++)
    t[i] = tolower(s[i]);
return t;

}

Here is my main function

// MovieInfoApp.cpp
#include "Movie.h" // include Movie class definition
#include "Movies.h" // include Movies class definition
#include <iostream>
#include <string>
using namespace std;

void main() {
Movies movies("Box Office Mojo.txt");
string answer, key;
bool set = false; 
int movieCode, ant;
cout<< "Would you like to start the Movie search?";
cin>> answer;
while (answer =="y" ||answer =="Y")
{
    cout<< "would you like to enter a movie name or a movie number? (press 1      for movie name press 2 for number";
    cin>>ant;
    if (ant = 2)
    {

        cout << "Please enter the movie number: ";
        cin >> movieCode;
        Movie m = movies.getMovie(movieCode);
        if(m.getTitle().length() > 0)
        {
            cout << m.toString() << "\n";
        }
        else
        {
            cout << "\n Movie not found!\n\n" << endl;
        }
    }
    else if (ant =1)
    {   
        cout << "Please enter a keyword or title of the movie: ";
        cin >> key;
        Movies tester; // No default constructor error over here 
        tester.Test(key);
    }
    else 
    {
        cout<< "invalid entry please try again";
    }
    cout<< "Would you like to continute the Movie search?";
    cin>> answer;
}

}
  • 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-06-18T04:07:19+00:00Added an answer on June 18, 2026 at 4:07 am

    You are trying to declare tester with the default constructor, and you have Movie movies[1000] which uses the default constructor, but there is no default constructor for your class.

    You’ll need to provide an argument for tester or define a default constructor.

    For the array, even if you do define a default constructor so that it works, I recommend not using arrays that will be stored directly in the object because then your objects are really huge (and perhaps surprise you with an unexpected stack overflow). Use std::vector and that will take care of multiple problems.

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

Sidebar

Related Questions

I'm trying to write a program that reads 2 numbers from the user and
I am trying to write a program that asks a user for a ten
I'm trying to write a program that asks the user to enter a password
I'm trying to write a program that reads 2 numbers from the user and
i am trying to write a program that prompts the user to enter a
Im trying to write a program that allow a user to track their DVDs.
I'm trying to write a program that will validate a user input consisting of
I'm trying to write a C# program, where when a user enters some data
I am trying to write a program that will accept user input which will
Im trying to write a program that runs some shell commands wit emulated user

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.