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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:44:16+00:00 2026-06-10T17:44:16+00:00

edit* I’m dumb… Thanks for helping me this question is solved. * In my

  • 0

edit*
I’m dumb… Thanks for helping me this question is solved.
*
In my car class the code below keeps giving me an error on the << operators

cout << "Driver: " << driver->print(); 
cout << "Owner: " << owner->print();

The error says “no operator matches these operands.” This is my homework assignment so I do need to somehow from the driver call the print function. In the main function I’m not actually setting the driver or owner yet but that shouldn’t matter I wouldn’t think. Thanks in advance.

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

using namespace std;

class Person
{
public:
Person(string _name,int _age)
{
    _name = name;
    _age = age;
    cout << "Name: " << name << endl;
    cout << "Age: " << age << endl;
}
string getName()
{
    return name;
}
int getAge()
{
    return age;
}
int incrementAge()
{
    age +=1;
    return age;
}
void print()
{
    cout << "Name: " << name << endl;
    cout << "Age: " << age << endl;

}


private:
string name;
int age;

};

class Car
{
public:
Car (string m)
{
    model = m;
}
void setDriver(Person *d)
{
    *driver = *d;
}
void setOwner(Person *o)
{
    *owner = *o;
}
void print()
{
    cout << "Model: " << model << endl;
    cout << "Driver: " << driver->print();
    cout << "Owner: " << owner->print();
}




private:

string model;
Person *owner;
Person *driver;


};

int main()
{
vector<Person*>people;
vector<Car*>cars;
string name = "";
int age = 0;
string model = 0;
int sentValue = 0;
while (sentValue != -1)
{
    cout << "Enter name: ";
    cin >> name;
    cout << "Enter age: ";
    cin >> age;


    people.push_back(new Person(name, age));
    cout << "Enter car model: ";
    cin >> model;
            cars.push_back(new Car(model));
    cout << "Press -1 to stop, or 1 to enter info for others: ";
    cin >> sentValue;
}






//display car model, 
//owner’s name and age,
//and driver’s name and age.

system("pause");
return 0;
   }
  • 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-10T17:44:18+00:00Added an answer on June 10, 2026 at 5:44 pm

    Your print() function already sends the output to cout, so there is no need to try to send it there again. Instead of

    cout << "Driver: " << driver->print(); 
    

    you probably want

    cout << "Driver:" << endl;
    driver->print();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Paul has solved this one below. Thanks! I'm trying to resample (upscale) a
Edit: The below question was answered by this . I have a new updated
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
EDIT: This question was exceptionally dumb and made me look like a script kiddie,
edit: change of question if my code is like this: <form name=login action=https://login.extremebb.net/login method=post
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
Edit: I'm looking for solution for this question now also with other programming languages.
EDIT : I've gotten the famous question badge with this question, so I figured
Edit: Seems numerous people think this is a dumb idea, so I would appreciate
EDIT: Problem solved... and unrelated to the phrasing of the question... sorry for 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.