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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:57:17+00:00 2026-06-11T05:57:17+00:00

I know that this question has been asked before. I’ve tried implementing the answers,

  • 0

I know that this question has been asked before. I’ve tried implementing the answers, but am still running up against this error. If anyone has any advice, it would be greatly greatly appreciated. Below is the main file, the header file, and source file. Please let me know if you require any additional information. Thanks!

main.cpp

/* 
 * File:   main.cpp
 * Author: agoodkind
 *
 * Reads in a .list file from IMDB
 * Prompts user for Actor or Movie lookup
 * Iterates through file
 * Returns results of query
 * 
 */

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>

#include "ActorResume.h"

using namespace std;


// function prototypes
void printmenu(void);
void createMovieList(fstream &infile);
void movieCastLookup(void);
void costarLookup(ActorResume &, fstream &infile);

int main() {    

    char choice;                //user menu selection
    bool not_done = true;       // loop control flag

    // create input file stream
    fstream infile;
    // CHANGE BACK TO NON-TEST!! 
    infile.open("/Users/agoodkind/Documents/CUNY/Analysis_and_Design/Assignments/Assignment1/actorsTEST.2010.list", ios::in);


    do {
        printmenu();
        cin >> choice;
        switch(choice)
        {
            case 'q':
            case 'Q':
                infile.close();
                not_done = false;
                break;
            case 'a':
            case 'A':
                createMovieList(infile);
                break;
            case 'm':
            case 'M':
                movieCastLookup();
                break;
            default:
                cout << endl << "Error: '" << choice << "' is an invalid selection -  try again" << endl;
                break;
        } //close switch

    } // close do() loop

    // exit program
    while (not_done);
    return 0;
} // close main()

/* Function printmenu()
 * Input:
 *  none
 * Process:
 *  Prints the menu of query choices
 * Output:
 *  Prints the menu of query choices
 */
void printmenu(void) {
    cout << endl << endl;
    cout << "Select one of the following options:" << endl;
    cout << "\t****************************" << endl;
    cout << "\t    List of Queries         " << endl;
    cout << "\t****************************" << endl;
    cout << "\t     A -- Look Up Actors' Costars" << endl;
    cout << "\t     M -- Movie Cast List" << endl;
    cout << "\t     Q -- Quit" << endl;
    cout << endl << "\tEnter your selection: ";
    return;    
}

/* Function costarLookup()
 * Input:
 *      Actor name
 * Process:
 *      Looks up all actors also in actor's movieList
 * Output:
 *      Prints list of costars
 */
void createMovieList(fstream &infile) {

    string actorName; // actor's name to be queried

    cout << endl << "Enter Actor Name: ";
    cin >> actorName;

    ActorResume *ar = new ActorResume(actorName);

    // add movie list to ActorCostars ADT created above
    // string for readline()
    string line;

    if (infile.is_open()) { //error checking to ensure file is open
        infile.seekg(0, ios::beg); // to be safe, reset get() to beginning of file
        while (infile.good()) { //error checking to ensure file is being read AND not end-of-file

            bool actor_found = false; // checks if actor name has been found
            getline(infile,line);

            if (line == actorName) {
                actor_found = true;
            }

            // add movies to actor's movieList
            while (actor_found && line[0] == '\t') {
                ar.addMovie(line);
            } 
        }
    }

    costarLookup(*ar, infile);
    delete ar;

} // close costarLookup()


void costarLookup(ActorResume actRes, fstream &infile) {

    // string for readline()
    string line;

    // vector to store costar names
    vector<string> costars;

    if (infile.is_open()) {             // error checking to ensure file is open

        infile.seekg(0, ios::beg);      // reset get() to beginning of file
        while (infile.good()) {         // error checking to ensure file is being read AND not end-of-file

            // while looping through file, store each actor's name
            string actorName;

            getline(infile,line);

            // check if first character is an alphanumeric character
            if (line[0] != '\t' && line[0] != NULL) {
                actorName = line;
            }

            // add actors name to list of costars
            if (actRes.movieInList(line)) {
                costars.push_back(actorName);
            }
        }
    }
    if (costars.size() == 0) {
        cout << "No costars found";
    }
    else if (costars.size() > 0) {
        cout << "Costars of " << actRes.getActorName() << ": " << endl;
        for (int i = 0; i < costars.size(); i++) {
            cout << "* " << costars[i];
        }
    }
}

ActorResume.h

/* 
 * ActorResume Specification Class
 */

#ifndef ACTORRESUME_H
#define ACTORRESUME_H

#include <iostream>
#include <string>
#include <vector>
#include <cstring>

using namespace std;

// ActorResume declaration
class ActorResume {

private:
    string actorName;
    vector<string> movieList;

public:

    //default constructor
    ActorResume() {
//        actorName = NULL;
        movieList.clear();
    }

    //typical constructor implemented for creating ActorResume
    ActorResume(string aName) {
        actorName = aName;
        movieList.clear();
    }

    // member functions
    void addMovie(string);
    string getActorName();
    bool movieInList(string);
//    void printMovieList();

};


#endif  /* ACTORRESUME_H */

ActorResume.cpp

// ActorResume Implementation

#include <iostream>
#include <string>
#include <vector>
#include <cstring>

#include "ActorResume.h"

/*
 * ActorResume function addMovie()
 * Input:
 *      Movie Name
 * Process:
 *      adds movie to movieList
 * Output:
 *      None
 */
void ActorResume::addMovie(string movie) {
    movieList.push_back(movie);
//    return;
}

/*
 * ActorReusme function getActorName()
 * Input:
 *      None
 * Process:
 *      returns actor's name
 * Output:
 *      String of actor's name
 */
string ActorResume::getActorName() {
    return actorName;
}

/*
 * ActorResume function movieInList()
 * Input:
 *      string to search for
 * Process:
 *      searches movieList vector for string
 * Output:
 *      If movie is found, true
 *      Else, false
 */
bool ActorResume::movieInList(string movie) {
    for(size_t i = movieList.size() - 1; i != (size_t)-1; i--) {
        if (movieList[i] == movie) {
            return true;
        }
    }
    return false;
}

Error:

main.cpp: In function 'void createMovieList(std::fstream&)':
main.cpp:124: error: request for member 'addMovie' in 'ar', which is of non-class type 'ActorResume*'
  • 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-11T05:57:18+00:00Added an answer on June 11, 2026 at 5:57 am

    Error request for member ‘Foo’ in ‘f’, which is of non-class type ‘Foo*’

    The error tells you all you need to know.

    ActorResume *ar = new ActorResume(actorName);
    

    ar is a pointer to an ActorResume object, not an ActorResume object in and of itself. So…

    ar.addMovie(line);
    

    Should be

    ar->addMovie(line);
    

    You use the -> operator to derefence a pointer and access members of the object it refers to, not the dot operator. A pointer has no members.

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

Sidebar

Related Questions

I know that this sort of question has been asked here before, but still
I know this sort of question has been asked before , but I still
I know this question has been asked before, but none of the previous answers
I know this question has been asked before but I still haven't seen a
I know that maybe this question has been asked before, but I can't seem
I know this question has been asked before, but I have tried the given
I know that this question has been asked before, but I'm looking for a
I know that this question has been asked previously, but before you give me
I know this question has been asked before and I read all the answers
I know that the question has been asked before , but it's been two

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.